Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1db2f76

Browse files
committed
Cambiadas las plantillas del sitio admin corresponiendtes a modelos, question , choice y página princial
1 parent 38be6a7 commit 1db2f76

File tree

6 files changed

+134
-4
lines changed

6 files changed

+134
-4
lines changed

‎apps/polls/admin.py‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
from django.contrib import admin
2-
from .models import Question
2+
from .models import Question, Choice
33

44
# Register your models here.
55

6-
admin.site.register(Question)
6+
# modificando los formularios del sitio admin
7+
# admin.site.register(Question)
8+
admin.site.register(Choice)
9+
10+
11+
# primera modificación
12+
# class QuestionAdmin(admin.ModelAdmin):
13+
# fields = ['pub_date', 'question_text']
14+
15+
class ChoiceInline(admin.TabularInline):
16+
model = Choice
17+
extra = 3
18+
19+
20+
class QuestionAdmin(admin.ModelAdmin):
21+
fieldsets = [
22+
(None, {'fields': ['question_text']}),
23+
('Date Information', {'fields': ['pub_date'], 'classes': ['collapse']}),
24+
]
25+
26+
inlines = [ChoiceInline]
27+
28+
list_display = ('question_text', 'pub_date', 'was_published_recently')
29+
30+
list_filter = ['pub_date']
31+
32+
search_fields = ['question_text']
33+
34+
35+
admin.site.register(Question, QuestionAdmin)

‎apps/polls/models.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def was_published_recently(self):
1313
now = timezone.now()
1414
return now - datetime.timedelta(days=1) <= self.pub_date <= now
1515

16+
was_published_recently.admin_order_field = 'pub_date'
17+
was_published_recently.boolean = True
18+
was_published_recently.short_description = 'Published recently?'
19+
1620
def __str__(self):
1721
return self.question_text
1822

‎apps/polls/static/polls/style.css‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ li a{
44

55
body{
66
background: lightgrey url("images/background.gif") no-repeat;
7-
}
7+
}
8+
9+

‎mysite/settings.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
TEMPLATES = [
5656
{
5757
'BACKEND': 'django.template.backends.django.DjangoTemplates',
58-
'DIRS': [],
58+
'DIRS': [os.path.join(BASE_DIR, 'templates')],
5959
'APP_DIRS': True,
6060
'OPTIONS': {
6161
'context_processors': [

‎templates/admin/base_site.html‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% extends "admin/base.html" %}
2+
3+
{% block title %}Polls Administration{% endblock %}
4+
5+
{% block branding %}
6+
<h1 id="site-name"><a href="{% url 'admin:index' %}">Polls Administration</a></h1>
7+
{% endblock %}
8+
9+
{% block nav-global %}{% endblock %}

‎templates/admin/index.html‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{% extends "admin/base_site.html" %}
2+
{% load i18n static %}
3+
4+
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}">{% endblock %}
5+
6+
{% block coltype %}colMS{% endblock %}
7+
8+
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
9+
10+
{% block breadcrumbs %}{% endblock %}
11+
12+
{% block content %}
13+
<div id="content-main">
14+
15+
{% if app_list %}
16+
{% for app in app_list %}
17+
<div class="app-{{ app.app_label }} module">
18+
<table>
19+
<caption>
20+
<a href="{{ app.app_url }}" class="section" title="{% blocktrans with name=app.name %}Models in the {{ name }} application{% endblocktrans %}">{{ app.name }}</a>
21+
</caption>
22+
{% for model in app.models %}
23+
<tr class="model-{{ model.object_name|lower }}">
24+
{% if model.admin_url %}
25+
<th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th>
26+
{% else %}
27+
<th scope="row">{{ model.name }}</th>
28+
{% endif %}
29+
30+
{% if model.add_url %}
31+
<td><a href="{{ model.add_url }}" class="addlink">{% trans 'Add' %}</a></td>
32+
{% else %}
33+
<td>&nbsp;</td>
34+
{% endif %}
35+
36+
{% if model.admin_url %}
37+
{% if model.view_only %}
38+
<td><a href="{{ model.admin_url }}" class="viewlink">{% trans 'View' %}</a></td>
39+
{% else %}
40+
<td><a href="{{ model.admin_url }}" class="changelink">{% trans 'Change' %}</a></td>
41+
{% endif %}
42+
{% else %}
43+
<td>&nbsp;</td>
44+
{% endif %}
45+
</tr>
46+
{% endfor %}
47+
</table>
48+
</div>
49+
{% endfor %}
50+
{% else %}
51+
<p>{% trans "You don't have permission to view or edit anything." %}</p>
52+
{% endif %}
53+
</div>
54+
{% endblock %}
55+
56+
{% block sidebar %}
57+
<div id="content-related">
58+
<div class="module" id="recent-actions-module">
59+
<h2>{% trans 'Recent actions' %}</h2>
60+
<h3>{% trans 'My actions' %}</h3>
61+
{% load log %}
62+
{% get_admin_log 10 as admin_log for_user user %}
63+
{% if not admin_log %}
64+
<p>{% trans 'None available' %}</p>
65+
{% else %}
66+
<ul class="actionlist">
67+
{% for entry in admin_log %}
68+
<li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
69+
{% if entry.is_deletion or not entry.get_admin_url %}
70+
{{ entry.object_repr }}
71+
{% else %}
72+
<a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
73+
{% endif %}
74+
<br>
75+
{% if entry.content_type %}
76+
<span class="mini quiet">{% filter capfirst %}{{ entry.content_type }}{% endfilter %}</span>
77+
{% else %}
78+
<span class="mini quiet">{% trans 'Unknown content' %}</span>
79+
{% endif %}
80+
</li>
81+
{% endfor %}
82+
</ul>
83+
{% endif %}
84+
</div>
85+
</div>
86+
{% endblock %}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /