Opened 9 months ago

Closed 8 months ago

#20853 closed Bug (wontfix)

Cannot find documentation on Options.module_name and Options.model_name

Reported by: markisus@… Owned by: nobody
Component: Documentation Version: 1.5
Severity: Normal Keywords: documentation
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm using Django 1.5 and looking at the docs here:

As per 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.

Attachments (0)

Change History (2)

comment:1 Changed 9 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 8 months ago by charettes

  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.