diff --git a/websiteProj/db.sqlite3 b/websiteProj/db.sqlite3 index e69de29..bef85be 100644 Binary files a/websiteProj/db.sqlite3 and b/websiteProj/db.sqlite3 differ diff --git a/websiteProj/polls/__pycache__/admin.cpython-310.pyc b/websiteProj/polls/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..183bb71 Binary files /dev/null and b/websiteProj/polls/__pycache__/admin.cpython-310.pyc differ diff --git a/websiteProj/polls/__pycache__/apps.cpython-310.pyc b/websiteProj/polls/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..93006e3 Binary files /dev/null and b/websiteProj/polls/__pycache__/apps.cpython-310.pyc differ diff --git a/websiteProj/polls/__pycache__/models.cpython-310.pyc b/websiteProj/polls/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..6f88ae3 Binary files /dev/null and b/websiteProj/polls/__pycache__/models.cpython-310.pyc differ diff --git a/websiteProj/polls/admin.py b/websiteProj/polls/admin.py index 8c38f3f..62d6b4f 100644 --- a/websiteProj/polls/admin.py +++ b/websiteProj/polls/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin # Register your models here. +from .models import Question + +admin.site.register(Question) diff --git a/websiteProj/polls/migrations/0001_initial.py b/websiteProj/polls/migrations/0001_initial.py new file mode 100644 index 0000000..78d6449 --- /dev/null +++ b/websiteProj/polls/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 4.0.6 on 2022-07-05 01:24 + +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.DateTimeField(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/websiteProj/polls/migrations/__pycache__/0001_initial.cpython-310.pyc b/websiteProj/polls/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000..e9505d8 Binary files /dev/null and b/websiteProj/polls/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/websiteProj/polls/migrations/__pycache__/__init__.cpython-310.pyc b/websiteProj/polls/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..0d194cc Binary files /dev/null and b/websiteProj/polls/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/websiteProj/polls/models.py b/websiteProj/polls/models.py index 71a8362..f211d59 100644 --- a/websiteProj/polls/models.py +++ b/websiteProj/polls/models.py @@ -1,3 +1,20 @@ from django.db import models - +import datetime # Create your models here. +class Question(models.Model): + question_text = models.CharField(max_length = 200) + pub_date = models.DateTimeField('Date Published') + + def __str__(self): + return self.question_text + + def was_published_recently(self): + return self.pub_date >= timezone.now() - datetime.timedelta(days = 1) + +class Choice(models.Model): + question = models.ForeignKey(Question, on_delete = models.CASCADE) + choice_text = models.CharField(max_length = 200) + votes = models.IntegerField(default = 0) + + def __str__(self): + return self.choice_text diff --git a/websiteProj/websiteProj/__pycache__/settings.cpython-310.pyc b/websiteProj/websiteProj/__pycache__/settings.cpython-310.pyc index 1dd32b5..dde7bba 100644 Binary files a/websiteProj/websiteProj/__pycache__/settings.cpython-310.pyc and b/websiteProj/websiteProj/__pycache__/settings.cpython-310.pyc differ diff --git a/websiteProj/websiteProj/settings.py b/websiteProj/websiteProj/settings.py index 35c545d..0ec7492 100644 --- a/websiteProj/websiteProj/settings.py +++ b/websiteProj/websiteProj/settings.py @@ -31,6 +31,7 @@ # Application definition INSTALLED_APPS = [ + 'polls.apps.PollsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes',