开始学习django的orm

main
roger 2 years ago
parent b1a10b3598
commit 39ae59dadb
  1. 1
      .gitignore
  2. 0
      orm/__init__.py
  3. 18
      orm/db.py
  4. 5
      polls/tests.py

1
.gitignore vendored

@ -1 +1,2 @@
/.idea/*
/venv/

@ -0,0 +1,18 @@
from django.db import models
class BaseUserInfo(models.Model):
id = models.AutoField(verbose_name='编号', primary_key=True)
username = models.CharField(verbose_name='用户名', max_length=30)
password = models.CharField(verbose_name='密码', max_length=20)
status = models.CharField(verbose_name='状态', max_length=1)
createdate = models.DateField(verbose_name='创建日期', db_column='createDate')
def __str__(self):
return self.id
class Meta:
managed = False
verbose_name = '人员基本信息'
db_table = 'UserBaseInfo'

@ -11,3 +11,8 @@ class QuestionModelTests(TestCase):
time = timezone.now() + datetime.timedelta(days=30)
future_question = Question(pub_date=time)
self.assertIs(future_question.was_published_recently(), False)
def test_was_published_recently_with_old_question(self):
time = timezone.now() - datetime.timedelta(days=1, seconds=1)
old_question = Question(pub_date=time)
self.assertIs(old_question.was_published_recently(), False)

Loading…
Cancel
Save