Login

Snippets by onlinehero

Snippet List

Compact list_filter

When doing a list_filter on some object in the Django interface, every single item will be displayed. This is not always smart when very long list of choices can be displayed, even though the majority of these choices might not even exist in the database at all. Using this script will only display a filtering possibility for those items actually present in the database. This script is not generic, and you will need to change the lines noted "Change this", since I cannot know what exactly you need to filter. There is possibly a way to make this completely generic, and I hope this will inspire someone to make it!

  • admin-interface
  • compact
  • list_filter
Read More

Extended logging module

The django_admin_log only logs changes, not simple requests. Sometimes it can be useful to log when a user of your admin interface is checking out important data, for instance if you are making a system with personal sensitive data, that needs to comply with government / company policies. This will log such hits to the django_admin_log by overriding the change_view method in ModelAdmin. So you must override this method in all classes you want to have logged.

  • log
  • request
  • logging
  • django-admin
  • django_admin_log
  • extended
  • change_view
Read More

onlinehero has posted 2 snippets.