Skip to content

telminov/sw-django-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/',
]

About

Soft Way company django utils

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published