Login

Snippets by tgandor

Snippet List

Conditional INSTALLED_APPS entry

Some INSTALLED_APPLICATIONS applications may not be critical for your website to work - for example you may only need them for development - like 'django_extensions' or 'debug_toolbar'. They needn't be installed actually for the site to work. This way you can avoid discussions with other developers if some application should be included, or is it just spam, because if they don't like it, they don't have to install it. On a production server you can leave this not installed, to avoid security concerns like a possibility to IP-spoof and see the debug toolbar.

  • configuration
  • settings
  • conditional
  • installed_apps
Read More

Read-only Model Form Base Class

The simplest way of displaying a "details" table about any model, is to show a ModelFrom with all fields readonly or (selects) disabled. Also, the labels are preferably translatable, not just capitalized names of the column tables in your models. So the constructor translates the field labels as well.

  • form
  • readonly
Read More

View all log entries in the admin 2

Based on: [View all log entries in the admin](https://djangosnippets.org/snippets/2484/) Improvements: * No crash on `object_link` when reverse route missing, * Filter by users present in the log AND in database currently * Other filters on users - only superusers / only staff (modify to fit your needs) EDIT: Incorporated `action_description` from [django-logentry-admin](https://github.com/yprez/django-logentry-admin). * The list filter now has human-friendly action names, and the table also. * Refactored list filter class hierarchy.

  • admin
  • list-filter
  • logentry
Read More

tgandor has posted 4 snippets.