diff --git a/docs/index.rst b/docs/index.rst index c4cdc8a..dceeb22 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,1267 +19,46 @@ Report bugs at http://github.com/bradleyayers/django-tables2/issues .. toctree:: :hidden: - internal + pages/tutorial + pages/table-data + pages/accessors + pages/order-by-accessors + pages/swapping-columns + pages/column-headers + pages/pagination + pages/custom-rendering + pages/query-string-fields + pages/column-attributes + pages/builtin-columns + pages/template-tags + pages/template-filters + pages/generic-mixins + pages/table-mixins + pages/tables-for-models + pages/localization-control + pages/api-reference + pages/upgrading-from-v1 + pages/glossary + pages/internal -Tutorial -======== -1. ``pip install django-tables2`` -2. Add ``'django_tables2'`` to ``INSTALLED_APPS`` -3. Add ``'django.core.context_processors.request'`` to ``TEMPLATE_CONTEXT_PROCESSORS`` -We're going to run through creating a tutorial app. Let's start with a simple model:: - # tutorial/models.py - class Person(models.Model): - name = models.CharField(verbose_name="full name") -Add some data so you have something to display in the table. Now write a view -to pass a ``Person`` queryset into a template:: - # tutorial/views.py - from django.shortcuts import render - def people(request): - return render(request, "people.html", {"people": Person.objects.all()}) -Finally, implement the template: -.. sourcecode:: django - {# tutorial/templates/people.html #} - {% load render_table from django_tables2 %} - - -
- - - - {% render_table people %} - - -Hook the view up in your URLs, and load the page, you should see: -.. figure:: _static/tutorial.png - :align: center - :alt: An example table rendered using django-tables2 -While simple, passing a queryset directly to ``{% render_table %}`` doesn't -allow for any customisation. For that, you must define a `.Table` class. -:: - # tutorial/tables.py - import django_tables2 as tables - from tutorial.models import Person - class PersonTable(tables.Table): - class Meta: - model = Person - # add class="paleblue" to