Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#18399 closed New feature (fixed)

Add a `for_concrete_model` kwarg to `ContentTypeManager.get_for_models?`

Reported by: Simon Charette Owned by: Simon Charette
Component: contrib.contenttypes Version: 1.4
Severity: Normal Keywords: contenttypes proxy
Cc: charette.s@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

ContentTypeManager.get_for_models? always return the ContentType of the concrete model.

As highlighted in #17648 and #11154 there is cases that would benefit from the option of retrieving the ContentType of proxy models.

However changing ContentTypeManager.get_for_model? to return the ContentType of proxy models would be backward incompatible.

I suggest adding a for_concrete_model=True kwarg to ContentTypeManager.get_for_models? which defaults to <=1.4 behaviour.

Pull request to come.

Change History (5)

comment:1 by Simon Charette, 12 years ago

Looking at get_for_models implementation there doesn't seems to be way to add this flag while maintaining backward compatiblity since models are passed as *args...

Version 0, edited 12 years ago by Simon Charette (next)

comment:2 by Simon Charette, 12 years ago

Cc: charette.s@… added
Has patch: set

Added pull request with tests and docs.

comment:3 by Anssi Kääriäinen <akaariai@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [b6d533af4d03f27ea957baa5fd70f7d0b942ef9a]:

Fixed #18399 – Added a way to get ContentTypes for proxy models

Added kwargs for_concrete_model and for_concrete_models to ContentType
methods get_for_model() and get_for_models(). By setting the flag to
False, it is possible to get the contenttype for proxy models.

comment:4 by Omer Katz, 10 years ago

Does this resolve #11154 in any way?

comment:5 by Simon Charette, 10 years ago

This ticket adds a feature required to solve #11154.

Note: See TracTickets for help on using tickets.
Back to Top