The BaseMixin class adds the following to the template context:

  • path: self.request.path or home if the path is /
  • today: todays date (
  • request_path: self.request.path

Bullet (Hide)

If you create a form with a RadioSelect widget e.g:

send_email = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES)

Then you can hide the bullets on the page by using the kb-hide-bullet style e.g:

{% include '_form.html' with form_class='kb-hide-bullet' %}


We have (very nice) inline checkboxes:


To make all check boxes on a form appear on a single line add:

{% include '_form.html' with inline_checkbox=True ... %}

For more information, take a look at the documentation in the templates:

Date Picker

Using RequiredFieldForm will automatically set date fields to use the zebra datepicker control e.g:

from base.form_utils import RequiredFieldForm

class EventForm(RequiredFieldForm):


If your date control isn’t working as a date picker, then check your form code to see if you call self.fields[name].widget.attrs.update({'class'... on the field. This will overwrite the update done by the __init__ method on RequiredFieldForm.

File and Image Upload

If you include the _form.html template and you want to upload files, the add the multipart option:

{% include '_form.html' with multipart=True %}

FileDropInput Widget

To display a drag and drop file upload, set the widget for your form to FileDropInput.

For example assuming the following model is defined in your

class Document(TimedCreateModifyDeleteModel):
    file = models.FileField(upload_to='document')
    description = models.CharField(max_length=256)

    class Meta:
        verbose_name = 'Document'
        verbose_name_plural = 'Documents'

    def __str__(self):
        return '{}: {}'.format(self.file, self.description)

You can define a model form called DocumentForm as follows:

from django import forms
from base.form_utils import FileDropInput
from .models import Document

class DocumentForm(models.ModelForm):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name in ('file', 'description'):
                {'class': 'pure-input-2-3'}

    class Meta:
        model = Document
        fields = (
        widgets = {'file': FileDropInput}

or using RequiredFieldForm (which sets the widget to FileDropInput for all FileField and ImageFields) as follows:

from base.form_utils import RequiredFieldForm
from .models import Document

class DocumentForm(RequiredFieldForm):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name in ('file', 'description'):
                {'class': 'pure-input-2-3'}

    class Meta:
        model = Document
        fields = (


In the HTML template:

<div id="pdf-viewer"></div>

At the end of the template:

{% block script_extra %}
  {{ block.super }}
  {% include 'base/_pdfobject.html' %}
  <script>PDFObject.embed("{% url '' %}", "#pdf-viewer");</script>
    .pdfobject-container { height: 800px;}
    .pdfobject { border: 1px solid #666; }
{% endblock script_extra %}


If you get Failed to load PDF document in Google Chrome, see PDFObject


from base.view_utils import BaseMixin, RedirectNextMixin


This example is for use with an update view and the POST method.

Add the request context processor to settings:

'context_processors': [
    # ...

In the calling template:

<a href="{% url 'dash.document.update' %}?next={{ request.path }}" class="pure-menu-link">

In the view, add the RedirectNextMixin:

from django.contrib.auth import REDIRECT_FIELD_NAME
from base.view_utils import BaseMixin, RedirectNextMixin

class ContactDetailView(
    LoginRequiredMixin, StaffuserRequiredMixin,
    RedirectNextMixin, BaseMixin, DetailView):

If required, add a get_success_url method:

def get_success_url(self):
    next_url = self.request.POST.get(REDIRECT_FIELD_NAME)
    if next_url:
        return next_url
        return reverse('dash.document.detail', args=[])

Our standard _form.html template includes this section:

  {% if next %}
    <input type="hidden" name="next" value="{{ next }}" />
  {% endif %}

In the menu of the form template:

<li class="pure-menu-item">
  {% if next %}
    <a href="{{ next }}" class="pure-menu-link">
      <i class="fa fa-reply"></i>
  {% else %}
    <a href="{% url 'dash.document.issue.detail' %}" class="pure-menu-link">
      <i class="fa fa-reply"></i>
  {% endif %}



class SnippetForm(RequiredFieldForm):


We have a few standard URLs:

  • logout
  • login
  • project.home the home page of the web site.
  • project.dash the home page for a member of staff (or logged in user if the project requires it).
  • project.settings, the project settings. Usually only accessible to a member of staff.