django smartround filter
rounds floats in more human readable format e.g. 341.123434 mUSD -> 341mUSD 0.45345345 mUSD -> 0.5 mUSD 0.034545 mUSD -> 0.03 mUSD 0.0014545 mUSD -> 0.001 mUSD etc.
- smart round
- smartfloatformat
rounds floats in more human readable format e.g. 341.123434 mUSD -> 341mUSD 0.45345345 mUSD -> 0.5 mUSD 0.034545 mUSD -> 0.03 mUSD 0.0014545 mUSD -> 0.001 mUSD etc.
It will return list of all remaining migrations
It will help for change URL in available languages in template
[DRF browsable API interface](http://www.django-rest-framework.org/api-guide/filtering/#customizing-the-interface) for django-rest-framework-gis [InBBoxFilter](https://github.com/djangonauts/django-rest-framework-gis#inbboxfilter) Tested with Django==1.10.5 django-filter==1.0.1 djangorestframework==3.5.4 djangorestframework-gis==0.11 
Two simple tags to extract the template filename from within a template.
Small example of how to write your own function. This is not available in Django. The function just replaces static text strings, regular expressions are not supported. The syntax is the same in SQLite, PostgreSQL, MySQL and Oracle.
The code was placed inside a helper file without using a class. The Django validator was not designed to work with validator classes, it would appear, so retrieving the value from the field proved to be a hassle. Just create a helper file, import it on your model, and use the validator in the standard way, as such: cnpj = models.CharField(unique=True, max_length=14, validators=[validate_CNPJ]) cpf = models.CharField(unique=True, max_length=14, validators=[validate_CPF])
Simply Gravatar Templatetags, for example the name of this templatetag is: `templatetags/gravatar_tags.py`, this supported for Python2 or Python3.
FileField that checks that the file is a valid CSV and if specified in `expected_fieldnames` checks that the fields match exactly. The widget's `accept` parameter is set to accept csv, text and excel files. **TODO**: Validate the entirety of the CSV file, not just the headers. But this should be enough for most use cases, as checking the whole file could be computationally expensive for huge files. Example usage: people = CSVField(expected_fieldnames=['First Name', 'Last Name'])
This snippets is inspired from [#2995](https://djangosnippets.org/snippets/2995/) but add the following: * get rid of `singledispatch` so we can use it with python2 without pip installing anything * streaming capabilities * the configuration params (header, fields, exclude...) are passed to the action function so we don't pollute the ModelAdmin class * fix utf8 issue in header
Django 1.10 Internationalization Middleware, more complete tutorial: https://python.web.id/blog/how-to-implement-django-internationalization/
Say you want to keep your API secure and thus it has authentication, but there's this one View action in a ViewSet which unlike the rest of the ViewSet's actions needs to allow free access without authentication. This solution applies the good old `IsAuthenticated` permission to all ViewSet actions except those defined in a `login_exempt_actions` list. That's a list of the ViewSet action's names. This is a simple solution for this particular problem, which I imagine could be quite common. Any case where the requirements are more complex should implement one of the DRF permissions extensions which allow for the use of logical operators. **NOTE**: Remember that `request.user` will be an `AnonymousUser` instance, so be careful with any code which assumes it'll be a `User` instance. This could be the case with, say, a custom `get_queryset` implementation.
The version of snippet that works with Django 1.9
This is a revised version of https://djangosnippets.org/snippets/2921/
Filter to remove words at the end of a string Example: Myvar: "My name is Arthur and django si awesome" {{myvar|wordend:4}} Output: "My name is Arthur"