Re: [Django] #34354: models. Manager annotate() queryset conflict with models.Model (was: Behaviour by design? models. Manager annotate() queryset conflict with models.Model)

4 views
Skip to first unread message

Django

unread,
Feb 19, 2023, 11:31:09 PM2/19/23
to django-...@googlegroups.com
#34354: models. Manager annotate() queryset conflict with models.Model
-------------------------------+--------------------------------------
Reporter: David Pratten | Owner: nobody
Type: New feature | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Normal | Resolution: duplicate
Keywords: Possible | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* type: Bug => New feature
* resolution: => duplicate


Comment:

You cannot add a field based on an annotation to the model as
`models.IntegerField()`. As far using annotations in `list_display` there
are open tickets for that so marking as a duplicate, see #14336 and
#27229.

> What is the correct way to add a computed field to a model in Admin
land?

The answer is in the error message: ''"which is not a **callable**, an
**attribute of 'MyPapersAdmin'**, or an **attribute or method on
'literature.MyPapers'**."''

--
Ticket URL: <https://code.djangoproject.com/ticket/34354#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages