Generic Templates

Nuit’s generic templates provide the front-end detail for common operations, such as listing objects. These tend to go hand-in-hand with Django’s Generic Views.

nuit/generic/list.html

Displays a list of objects, linking to their detail URL, with options for pagination and filtering. This is designed to be used with Nuit’s nuit.views.SearchableListView.

Arguments

The following arguments can be passed to the extend tag to change the behaviour of the list template:

base
Default:‘nuit/base.html’

Defines the template which nuit/generic/list.html will extend. This defaults to nuit/base.html, but in most cases you will have made customisations (such as menu items etc.) to your own base template, and need this template to extend your own.

search_verb
Default:‘Search’

Defines the verb to be displayed on the submit button of the search form, if applicable.

Blocks

The following blocks can be overridden in subsequent templates to customise the behaviour of the template. All blocks that are included in the template hierarchy are also available - by default, this means all blocks available in nuit/base.html.

Note

As always, the best way to override these blocks is to look at the source code for nuit/generic/list.html. This will give you a good idea about how Nuit implements parts of the template, and therefore a good indication of what is required if you wish to override the blocks.

title

Defines the title of the page, used in an <h1> element and in the <title>.

search_query

Displays above the list of objects when a search has been performed. Defaults to displaying the number of results and the term that was searched for.

object_list

Used to override the list of objects. By default, contains an unordered list of the object’s str representations that links to their get_absolute_url.

nuit/generic/400.html

A generic template designed for display when an HTTP status code of 400 is returned. Used by the nuit.handlers.handler400() handler.

nuit/generic/403.html

A generic template designed for display when an HTTP status code of 403 is returned. Used by the nuit.handlers.handler403() handler.

nuit/generic/404.html

A generic template designed for display when an HTTP status code of 404 is returned. Used by the nuit.handlers.handler404() handler.

nuit/generic/500.html

A generic template designed for display when an HTTP status code of 500 is returned. Used by the nuit.handlers.handler500() handler.

nuit/generic/login.html

A template designed for use with Django’s django.contrib.auth.login view. Use in your urls.py as such:

from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
    url(r'^', include('myapp.urls')),
    url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'nuit/generic/login.html'}),
)