Update the example app

This commit is contained in:
Bradley Ayers 2012-09-14 23:02:43 +10:00
parent 339c6e9d7e
commit 38bfda136d
5 changed files with 21 additions and 0 deletions

View File

@ -9,6 +9,7 @@ class Country(models.Model):
population = models.PositiveIntegerField(verbose_name=u"Población")
tz = models.CharField(max_length=50)
visits = models.PositiveIntegerField()
commonwealth = models.NullBooleanField()
class Meta:
verbose_name_plural = _("Countries")

View File

@ -1,5 +1,6 @@
# coding: utf-8
import django_tables2 as tables
from .models import Country
class CountryTable(tables.Table):
@ -7,6 +8,10 @@ class CountryTable(tables.Table):
population = tables.Column()
tz = tables.Column(verbose_name='time zone')
visits = tables.Column()
summary = tables.Column(order_by=("name", "population"))
class Meta:
model = Country
class ThemedCountryTable(CountryTable):

View File

@ -39,3 +39,7 @@ class ClassBased(SingleTableView):
template_name = "class_based.html"
class_based = ClassBased.as_view()
def tutorial(request):
return render(request, "tutorial.html", {"people": Person.objects.all()})

View File

@ -0,0 +1,10 @@
{% load render_table from django_tables2 %}
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" />
</head>
<body>
{% render_table people %}
</body>
</html>

View File

@ -9,6 +9,7 @@ admin.autodiscover()
urlpatterns = patterns('example.app.views',
url(r'^$', 'multiple'),
url(r'^class-based/$', 'class_based'),
url(r'^tutorial/$', 'tutorial'),
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),