-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So far we have set up our models for a question and a choice. We've a…
…lso set up the admin site and imported our question model over to admin site so it can be modified from there. Here are the next couple of steps Im going to take. 1. Merge this branch to the main GitHub repo. 2. Create a seperate branch for making changes, specifically to views and returning HTML files.
- Loading branch information
1 parent
91d6f2e
commit b671167
Showing
11 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
from .models import Question | ||
|
||
admin.site.register(Question) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')), | ||
], | ||
), | ||
] |
Binary file added
BIN
+1.01 KB
websiteProj/polls/migrations/__pycache__/0001_initial.cpython-310.pyc
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Binary file modified
BIN
+24 Bytes
(100%)
websiteProj/websiteProj/__pycache__/settings.cpython-310.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters