diff --git a/LCAdmin/db.sqlite3 b/LCAdmin/db.sqlite3 index 28bcae5..afe97ac 100644 Binary files a/LCAdmin/db.sqlite3 and b/LCAdmin/db.sqlite3 differ diff --git a/LCAdmin/polls/migrations/0001_initial.py b/LCAdmin/polls/migrations/0001_initial.py new file mode 100644 index 0000000..555a29f --- /dev/null +++ b/LCAdmin/polls/migrations/0001_initial.py @@ -0,0 +1,52 @@ +# Generated by Django 4.1 on 2022-09-09 02: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/LCAdmin/polls/models.py b/LCAdmin/polls/models.py index 71a8362..416d357 100644 --- a/LCAdmin/polls/models.py +++ b/LCAdmin/polls/models.py @@ -1,3 +1,22 @@ +import datetime from django.db import models +from django.utils import timezone -# 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 \ No newline at end of file