.. Created : 2018-02-03 @author: Eric Lapouyade django-listing documentation master file, ============== django-listing ============== Django app for building HTML listings / tables Installation ------------ Install with pip:: pip install django_listing Then declare the app in your settings.py :: INSTALLED_APPS = [ ... 'django_listing', ] Usage ----- The very basic setting is to create a view from the TemplateView class. in views.py:: from django.views.generic import TemplateView from demo.models import Employee class BasicUsageListingView(TemplateView): template_name = 'demo/basic_usage.html' extra_context = dict(employees_as_model=Employee) # See 'Employee' definition in "Read me first" at home page. In this exemple, ``Employee`` is a model and is exported as ``employees_as_model`` into the template ``demo/basic_usage.html``. If you want, you can also use ``get_context_data()`` method instead of ``extra_context`` attribute. As usual, you attach the view to an url in url.py:: from .views import * urlpatterns = [ ... path('basic_usage/', BasicUsageListingView.as_view(), name='basic_usage'), ... ] It is time to define the template ``demo/basic_usage.html``:: {% load django_listing %}
... {% render_listing_header %} ... ... {% render_listing employees_as_model per_page=5 %} ... {% render_listing_footer %}