This snippet holds your Django project from automatically changing language of the page to the best fitting one by discovering the client browser language.
I personally needed to show the page to the user for the first time in the default language (English), although there were some translations. User can still change the language (via session cookies).
Insert this middleware BEFORE the Django's `django.middleware.locale.LocaleMiddleware` in settings.
Mixin to support pagination when randomizing querysets.
Requirements: Postgres, Django Sessions
Note: This shouldn't be used on large complex datasets. It utilizes the relatively slow method of '?' randomized sorting. Use with caution.
Todo: MySQL support, Support for larger datasets
I am used to load forms directly into modals using dajax but I found out I had to load the scripts using an ajax call from the browser.
You can see here an example of a dynamically loaded form and the function used to load the scripts.
This is a simple django snippet!
It is the *opposite of @login_required* decorator for Django views
Example
**@not_login_required**
```
def login_page(request):
...
```
For several projects I am using generic views instead of django-admin, I needed a generic view for constance instead of using their django-admin based app.
Obfuscate javascript strings.
* Convert
* `{{'Pita Hummus'|js_obfuscate_string}}`
* to something like
* `'P4itzga Hnumg7mubs'.replace(/[4zgn7b]/g,'')`
Making it hard to text-search for strings in your code.
I've reimplemented the code I found somewhere on the web within my models file. The earlier version was incapable of converting all formats to JPG while this code converts all formats and compresses all of them successfully.
You need to have PILLOW installed for this to work.
I've reimplemented the code I found somewhere on the web within my models file. The earlier version was incapable of converting all formats to JPG while this code converts all formats and compresses all of them successfully.
## required
* `{% load trans%}`before using this snippets
* Add this [template filter](https://djangosnippets.org/snippets/2253/) to your custom templatetags and load it before using this snippets
* Bootstrap framework
Decorating a whole view involves overriding the dispatch method so you can decorate it, even if all you do is a passthrough. This creates a class decorator for decorating CBVs. For example, if you want to make a view require a login:
@decorate_dispatch(login_required)
class MyCBV(TemplateView):
...