Update the example app
This commit is contained in:
parent
339c6e9d7e
commit
38bfda136d
|
@ -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")
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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()})
|
||||
|
|
|
@ -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>
|
|
@ -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')),
|
||||
|
|
Loading…
Reference in New Issue