Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9926a8a017
4 changed files with 33 additions and 3 deletions
|
@ -55,7 +55,7 @@ ROOT_URLCONF = 'mysite.urls'
|
|||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
|
|
|
@ -2,5 +2,20 @@ from django.contrib import admin
|
|||
|
||||
from .models import Question, Choice
|
||||
|
||||
admin.site.register(Question)
|
||||
admin.site.register(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)
|
||||
#admin.site.register(Choice)
|
||||
|
|
|
@ -15,6 +15,12 @@ class Question(models.Model):
|
|||
def was_published_recently(self):
|
||||
now = timezone.now()
|
||||
return now - datetime.timedelta(days=1) <= self.pub_date <= now
|
||||
def was_published_recently(self):
|
||||
now = timezone.now()
|
||||
return now - datetime.timedelta(days=1) <= self.pub_date <= now
|
||||
was_published_recently.admin_order_field = 'pub_date'
|
||||
was_published_recently.boolean = True
|
||||
was_published_recently.short_description = 'Published recently?'
|
||||
#def was_published_recently(self):
|
||||
#return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
|
||||
|
||||
|
|
9
kjg/django/mysite/polls/templates/admin/base_site.html
Normal file
9
kjg/django/mysite/polls/templates/admin/base_site.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "admin/base.html" %}
|
||||
|
||||
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
|
||||
|
||||
{% block branding %}
|
||||
<h1 id="site-name"><a href="{% url 'admin:index' %}">Polls Administration</a></h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block nav-global %}{% endblock %}
|
Loading…
Reference in a new issue