Soft Way company django utils
- Either checkout
sw-django-utils
from GitHub, or install using pip:
pip install sw-django-utils
- Add
sw-django-utils
to yourINSTALLED_APPS
:
INSTALLED_APPS += [
'djutils',
]
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>
Add to settings
MIDDLEWARE += [
'djutils.middleware.LoginRequired',
]
LOGIN_URL = '/login/'
# exemptions if needed
LOGIN_EXEMPT_URLS = [
'^/static/',
]