diff --git a/polls/migrations/0001_initial.py b/polls/migrations/0001_initial.py new file mode 100644 index 0000000..4d30c43 --- /dev/null +++ b/polls/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 4.1 on 2022-08-30 01:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Question', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('question_text', models.CharField(max_length=200)), + ('pub_date', models.DateField(verbose_name='date published')), + ], + ), + migrations.CreateModel( + name='Choice', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('choice_text', models.CharField(max_length=200)), + ('votes', models.IntegerField(default=0)), + ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.question')), + ], + ), + ] diff --git a/polls/models.py b/polls/models.py index 71a8362..41459ac 100644 --- a/polls/models.py +++ b/polls/models.py @@ -1,3 +1,13 @@ from django.db import models + # Create your models here. +class Question(models.Model): + question_text = models.CharField(max_length=200) + pub_date = models.DateField('date published') + + +class Choice(models.Model): + question = models.ForeignKey(Question, on_delete=models.CASCADE) + choice_text = models.CharField(max_length=200) + votes = models.IntegerField(default=0) diff --git a/requirement.txt b/requirement.txt new file mode 100644 index 0000000..318a3cf Binary files /dev/null and b/requirement.txt differ diff --git a/w3cschool_demo/settings.py b/w3cschool_demo/settings.py index 103d8b4..c3f0fb5 100644 --- a/w3cschool_demo/settings.py +++ b/w3cschool_demo/settings.py @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'polls.apps.PollsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -75,8 +76,12 @@ WSGI_APPLICATION = 'w3cschool_demo.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'django_w3cschool_demo', + 'USER': 'django', + 'PASSWORD': 'djangopwd', + 'HOST': 'home.rogersun.online', + 'PORT': '3306' } } @@ -103,9 +108,9 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/4.1/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'zh-hans' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Asia/Shanghai' USE_I18N = True