Login

Snippets by luc_j

Snippet List

ForeignKey filterspec

Unfortunately, it is not possible currently to use foreign keys in list filter of the admin website. list_filter=['city__country'] doesn't work. This filter spec tries to workaround this problem. It is also possible to have 2 filters for a foreign-key field but it requires to add a dummy field to the model. Set the fk_filterspec dictionnary on this dummy field and add 'fk':'real-field' to the dict.

  • foreignkey
  • django-admin
  • filterspec
Read More

luc_j has posted 2 snippets.