Soft Way company django utils.


License
MIT
Install
pip install sw-django-utils==0.0.48

Documentation

sw-django-utils

Soft Way company django utils

Installation

  1. Either checkout sw-django-utils from GitHub, or install using pip:
pip install sw-django-utils
  1. Add sw-django-utils to your INSTALLED_APPS:
INSTALLED_APPS += [
    'djutils',
]

Using Sorting

In view:

class Search(SortMixin, ListView):
    model = models.ExampleModel
    template_name = 'ExampleSearch.html'
    sort_params = ['example_field', 'date_start', 'date_end']

In template:

{% load djutils %}
<table>
    <tr>
        <th>#</th>
        {% sort_th 'example_field' 'Example' %}
        {% sort_th 'date_start' 'Created' %}
        {% sort_th 'date_end' 'Expiring date' %}
    </tr>
    ...
</table>    

Using LoginRequired middleware

Add to settings

MIDDLEWARE += [
   'djutils.middleware.LoginRequired',
]

LOGIN_URL = '/login/'

# exemptions if needed
LOGIN_EXEMPT_URLS = [
  '^/static/',
]