.. 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 %} You need to load django_listing tags at the very begining of the template, then include ``{% render_listing_header %}`` template in the ``...`` part of the template, and ``{% render_listing_footer %}`` template at the very end of the ``...`` part of the template. This will automatically add necessary CSS and JS in your page. Then you can use the ``{% render_listing ... %}`` tag where you want to display the listing. First parameter must be a Django model, a queryset, an iterable or a ``Listing`` instance. Some parameters can be added : here the listing will have 5 rows per page. **Note :** jquery, popper, bootstrap and datetimepicker javascripts are not mandatory for basic listings Demo ---- Actually, the detailed documentation is under construction. The best way to see how to use django-listing is to see the demo code here : `django-listing-demo `_ If you have docker you can run the demo with this command:: docker run -p 8123:8123 elapouya/django-listing-demo And then open your browser at this url : http://localhost:8123 To install docker on Linux, just use this command:: curl -sSL https://get.docker.com/ | sh Otherwise, you can upload from here : https://docs.docker.com/get-docker/ Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search`