ABSOLUTE_URL_OVERRIDES docs are inconsistent with how they actually work
|Reported by:||ubernostrum||Owned by:||jacob|
|Cc:||nsteinmetz@…||Triage Stage:||Ready for checkin|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by ubernostrum)
The docs for the ABSOLUTE_URL_OVERRIDES setting state that the keys in that dictionary should be of the form app_label.modelname, with the model name capitalized, but the code in django/db/models/base.py which curries get_absolute_url looks for app_label.module_name, and module_name is normalized to lower-case by that point.
So, for example, the docs say to use weblog.Entry as a key in ABSOLUTE_URL_OVERRIDES, but get_absolute_url will actually look for weblog.entry.
I'm of two minds on how to solve this; the naive solution is to have the curried get_absolute_url look for opts.module_name.capitalize(), since that will make it consistent with the examples in the docs, but it's entirely possible that someone will create a model class with an all-lowercase name (which is, I assume, why module_name is normalizing it to lowercase), in which case the better solution is to change the docs.
Change History (9)
comment:1 Changed 9 years ago by ubernostrum
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:6 Changed 9 years ago by mtredinnick
- Triage Stage changed from Design decision needed to Accepted
Changed 9 years ago by ubernostrum
comment:7 Changed 9 years ago by ubernostrum
- Component changed from Metasystem to Documentation
- Owner changed from adrian to jacob
- Triage Stage changed from Accepted to Ready for checkin