From 39ae59dadb7840b68b491c001982ffb6c35fe38c Mon Sep 17 00:00:00 2001 From: roger Date: Tue, 4 Jul 2023 22:12:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=AD=A6=E4=B9=A0django?= =?UTF-8?q?=E7=9A=84orm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + orm/__init__.py | 0 orm/db.py | 18 ++++++++++++++++++ polls/tests.py | 5 +++++ 4 files changed, 24 insertions(+) create mode 100644 orm/__init__.py create mode 100644 orm/db.py diff --git a/.gitignore b/.gitignore index f1b7204..1293d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.idea/* +/venv/ diff --git a/orm/__init__.py b/orm/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/orm/db.py b/orm/db.py new file mode 100644 index 0000000..cfd726d --- /dev/null +++ b/orm/db.py @@ -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' + diff --git a/polls/tests.py b/polls/tests.py index 06f0cfc..70e580f 100644 --- a/polls/tests.py +++ b/polls/tests.py @@ -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)