Code

Opened 8 years ago

Closed 7 years ago

#1821 closed defect (wontfix)

[patch] use module level attribute app_label for models. Support interactive use with minimal effort.

Reported by: mir@… Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I'm really annoyed that you cannot use models interactively, or pychecker you model. To circumvent this restriction, I propose to add a module level attribute for model modules, such as

app_label = "applabel"

The attached patch also creates a more friendly error message in the case of interactive use instead of IndexError. It now says:

"""Interactive model use not directly supported.
To circumvent this restriction, add an app_label attribute to each model class or to
the model module."""

This might not be the ideal solution, but is an easy one and really helps.

Attachments (1)

app_label.diff (1.2 KB) - added by mir@… 8 years ago.
patch

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by mir@…

patch

comment:1 Changed 8 years ago by mir@…

  • Summary changed from use module level attribute app_label for models. Support interactive use with minimal effort. to [patch] use module level attribute app_label for models. Support interactive use with minimal effort.

comment:2 Changed 8 years ago by adrian

  • Status changed from new to assigned

comment:3 Changed 8 years ago by Home

  • Type enhancement deleted

comment:4 Changed 8 years ago by mir@…

  • Type set to defect

Beware, this patch is now making problems with syncdb. syncdb does not recognize the label if you use app_label.

On the other side, I think the improved error message would be received well.

comment:5 Changed 7 years ago by anonymous

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

I retract this because of the problems I stated.

Add Comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.