#28822: Add DBCalculatedField to model to annotate models automatically -------------------------------------+------------------------------------- Reporter: Ilya | Owner: nobody Type: New feature | Status: new Component: Database layer | Version: dev (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Matthijs Kooijman): I found one more case where this feature would be tremendously useful: Admin filtering on annotations. Currently, you can very easily filter on fields in the admin, using `ModelAdmin.list_filter`, but to filter on an annotation, you need to implement your own `SimpleListFilter` that handles everything, potentially duplicating a lot of code that is already in `FieldListFilter` and its subclasses (I tried some wrapping and using `FieldListFilter.create` passing a field instance, which worked for a choice field but failed for `AllValuesFieldListFilter` because it insists looking up the reverse field path for the filtered field). If `DBCalculatedField`s (or something similar) would be implemented, it would become possible (possibly with some minor changes to the admin list filter code, but maybe not even that) to just specify the name of the annotion in`ModelAdmin.list_filter` and have a filter interface just like for a real field. -- Ticket URL: <https://code.djangoproject.com/ticket/28822#comment:9> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.9068ee31a74f4b2356ebe65666ca5561%40djangoproject.com.