diff --git a/mysite/db.sqlite3 b/mysite/db.sqlite3 index 06ee5aa..1f6e8ba 100644 Binary files a/mysite/db.sqlite3 and b/mysite/db.sqlite3 differ diff --git a/mysite/mysite/__pycache__/settings.cpython-311.pyc b/mysite/mysite/__pycache__/settings.cpython-311.pyc index 3c6b414..c36ebb4 100644 Binary files a/mysite/mysite/__pycache__/settings.cpython-311.pyc and b/mysite/mysite/__pycache__/settings.cpython-311.pyc differ diff --git a/mysite/mysite/settings.py b/mysite/mysite/settings.py index b048ffd..c6c5c73 100644 --- a/mysite/mysite/settings.py +++ b/mysite/mysite/settings.py @@ -55,7 +55,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [BASE_DIR / 'templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/mysite/polls/__pycache__/admin.cpython-311.pyc b/mysite/polls/__pycache__/admin.cpython-311.pyc index 2028c90..880badf 100644 Binary files a/mysite/polls/__pycache__/admin.cpython-311.pyc and b/mysite/polls/__pycache__/admin.cpython-311.pyc differ diff --git a/mysite/polls/__pycache__/models.cpython-311.pyc b/mysite/polls/__pycache__/models.cpython-311.pyc index 7df65ba..617bad3 100644 Binary files a/mysite/polls/__pycache__/models.cpython-311.pyc and b/mysite/polls/__pycache__/models.cpython-311.pyc differ diff --git a/mysite/polls/admin.py b/mysite/polls/admin.py index d446ad9..f53b235 100644 --- a/mysite/polls/admin.py +++ b/mysite/polls/admin.py @@ -1,4 +1,21 @@ from django.contrib import admin -from .models import Question -admin.site.register(Question) +from .models import Question, Choice + + +class ChoiceInLine(admin.TabularInline): + model = Choice + extra = 3 + +class QuestionAdmin(admin.ModelAdmin): + fieldsets = [ + (None, {"fields": ["question_text"]}), + ("Date information", {"fields": ["pub_date"], "classes": ["collapse"]}), + ] + inlines = [ChoiceInLine] + list_display = ["question_text", "pub_date", "was_published_recently"] + list_filter = ["pub_date"] + search_fields = ["question_text"] + + +admin.site.register(Question, QuestionAdmin) \ No newline at end of file diff --git a/mysite/polls/migrations/__pycache__/0002_question_is_active.cpython-311.pyc b/mysite/polls/migrations/__pycache__/0002_question_is_active.cpython-311.pyc index 5a55bd6..dafb34b 100644 Binary files a/mysite/polls/migrations/__pycache__/0002_question_is_active.cpython-311.pyc and b/mysite/polls/migrations/__pycache__/0002_question_is_active.cpython-311.pyc differ diff --git a/mysite/polls/models.py b/mysite/polls/models.py index 5bec727..6fa49d6 100644 --- a/mysite/polls/models.py +++ b/mysite/polls/models.py @@ -1,6 +1,7 @@ import datetime from django.db import models from django.utils import timezone +from django.contrib import admin # each class correspond to a db table # each variable inside a class correspond to a db column @@ -13,6 +14,11 @@ class Question(models.Model): def __str__(self): return self.question_text + @admin.display( + boolean=True, + ordering="pub_date", + description="Published recently?" + ) def was_published_recently(self): now = timezone.now() return now - datetime.timedelta(days=1) <= self.pub_date <= now diff --git a/mysite/polls/static/polls/style.css b/mysite/polls/static/polls/style.css new file mode 100644 index 0000000..37a2973 --- /dev/null +++ b/mysite/polls/static/polls/style.css @@ -0,0 +1,3 @@ +li a { + color: green; +} \ No newline at end of file diff --git a/mysite/polls/templates/polls/index.html b/mysite/polls/templates/polls/index.html index cc41400..04410ae 100644 --- a/mysite/polls/templates/polls/index.html +++ b/mysite/polls/templates/polls/index.html @@ -1,3 +1,7 @@ +{% load static %} + + + {% if latest_question_list %}