Skip to content

Commit

Permalink
So far we have set up our models for a question and a choice. We've a…
Browse files Browse the repository at this point in the history
…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
chrismvelez97 committed Jul 5, 2022
1 parent 91d6f2e commit b671167
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 1 deletion.
Binary file modified websiteProj/db.sqlite3
Binary file not shown.
Binary file added websiteProj/polls/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added websiteProj/polls/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions websiteProj/polls/admin.py
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)
32 changes: 32 additions & 0 deletions websiteProj/polls/migrations/0001_initial.py
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 not shown.
Binary file not shown.
19 changes: 18 additions & 1 deletion websiteProj/polls/models.py
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 websiteProj/websiteProj/__pycache__/settings.cpython-310.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions websiteProj/websiteProj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Application definition

INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down

0 comments on commit b671167

Please sign in to comment.