Login

Tag "null"

Snippet List

RelatedNullFilterSpec: django-admin custom filter all/null/not null/choices

A simple django-admin filter to replace standar RelatedFilterSpec with one with the "All"/"Null"/"Not null" options. It applies to all relational fields (ForeignKey, ManyToManyField). You can put the code in the `__init__.py` or wherever you want. The `_register_front` idea is copied on [this snippet](http://djangosnippets.org/snippets/1963/)

  • filter
  • admin
  • null
  • filterspec
  • ManyToManyField
  • ForeignKey
  • not-null
Read More

django-admin custom filter: IS NULL/IS NOT NULL

A simple django-admin filter to allow a boolean-like filter for IS NULL/IS NOT NULL. By default it applies to CharField, IntegerField, and FileField, but you can change this by editing NullFilterSpec.fields.

  • filter
  • admin
  • null
  • filterspec
Read More

TrueNoneField

This custom model field is a variant of NullBooleanField, that stores only True and None (NULL) values. False is stored as NULL. It's usefull for special purposes like unique/unique_together. One small problem is here, that False is not lookuped as None. This snippets is a response to [1830](http://www.djangosnippets.org/snippets/1830/)

  • null
  • field
  • custom-field
  • none
Read More

Null Field Admin Filter

This patch adds a new admin Filter, for Filtering nullable fields. It adds 3 possible choices: 'All' (no filter), 'Null' (it applies field__isnull=True filter), and 'With Value' (it filters null values). This patch is interesting when you have a Integer or String fields and you want to filter wether a value is set or not. In other case, it would show too many filtering options. Remember this is a patch and you must modify a django file in `django/contrib/admin/filterspecs.py`

  • filter
  • admin
  • null
Read More

Serving null files

Sometimes you have to serve null files. This quick hacky generic view lets you do that. The best example of that is robots.txt, I want my robots.txt to always be empty, at least for now. The other example would be favicon.ico, but that's more often used to actually fill a purpose.

  • null
  • files
  • views
Read More

5 snippets posted so far.