[Django] #20853: Cannot find documentation on Options.module_name and Options.model_name

38 views
Skip to first unread message

Django

unread,
Aug 2, 2013, 11:33:25 AM8/2/13
to django-...@googlegroups.com
#20853: Cannot find documentation on Options.module_name and Options.model_name
-------------------------------+---------------------------
Reporter: markisus@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.5
Severity: Normal | Keywords: documentation
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+---------------------------
I'm using Django 1.5 and looking at the docs here:
https://docs.djangoproject.com/en/1.5/ref/models/options/

As per http://stackoverflow.com/questions/725913/dynamic-meta-attributes-
for-django-models I'm trying to create a python metaclass to append a
string at the end of my model's permissions. However I could not find
documentation on Options.module_name (it seems to return the model name).
Furthermore I get that 'Options' object has no attribute 'model_name', but
I saw this attribute being used in some other code on the internet.

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

Django

unread,
Aug 2, 2013, 1:08:43 PM8/2/13
to django-...@googlegroups.com
#20853: Cannot find documentation on Options.module_name and Options.model_name
-------------------------------+--------------------------------------

Reporter: markisus@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.5
Severity: Normal | Resolution:

Keywords: documentation | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

See #19689 - I believe this attribute is considered a private API and thus
undocumented.

--
Ticket URL: <https://code.djangoproject.com/ticket/20853#comment:1>

Django

unread,
Aug 16, 2013, 4:36:13 PM8/16/13
to django-...@googlegroups.com
#20853: Cannot find documentation on Options.module_name and Options.model_name
-------------------------------+--------------------------------------
Reporter: markisus@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: wontfix

Keywords: documentation | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by charettes):

* status: new => closed
* resolution: => wontfix


Comment:

As pointed out by @timo the model `_meta` option is deliberately
undocumented since it's considered an internal API and thus isn't bound to
Django's backward compatibility policy.

However as the deprecation of `module_name` path taken in #19689 pointed
out we're aware this API is (ab)used in the wild and chose to deprecate it
as if it was public to prevent breakages in third-party applications.

The reason you're getting this `AttributeError` upon `_meta.model_name`
access is that property was only introduced in Django 1.6. I'm afraid
you'll have to access `_meta.module_name` and lower case it on Django <
1.6 to get the same result.

--
Ticket URL: <https://code.djangoproject.com/ticket/20853#comment:2>

Django

unread,
Apr 25, 2014, 11:18:11 AM4/25/14
to django-...@googlegroups.com
#20853: Cannot find documentation on Options.module_name and Options.model_name
-------------------------------+--------------------------------------
Reporter: markisus@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: wontfix

Keywords: documentation | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by francis@…):

I know this is an old bug, and what I'm suggesting is probably a very bad
idea, but in my case I'm stuck on 1.4.2 for a moment and need to use a
module that has been updated to the latest >=1.6 Django versions.

{{{
# Monkey Patch
from django.db.models.options import Options
@property
def monkeypatch__options__model_name(self):
return self.module_name.lower()
Options.model_name = monkeypatch__options__model_name
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20853#comment:3>

Reply all
Reply to author
Forward
0 new messages