Login

Snippets by mbee

Snippet List

regex search in admin forms

Despite warning coming from django developers, I'm still using admin classes to quickly get into reverse engineering databases. One feature is missing: searching into fields thanks to a regex. One dirty solution I found is to overwrite get_search_results. But most of the code comes from django itself. If anyone has a better idea ;) **Usage:** 1. works since get_search_results is part of ModelAdmin (1.5 if I remember well) 2. Inherit your Admin class from RegexModelAdmin 3. enclose by / the field you want to regex with: `search_fields = ['/field/', ]`

  • admin
  • search
  • regex
  • field
Read More

mbee has posted 1 snippet.