[patch] use module level attribute app_label for models. Support interactive use with minimal effort.
|Reported by:||Owned by:||Adrian Holovaty|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
Change History (6)
comment:1 Changed 11 years ago by
|Summary:||use module level attribute app_label for models. Support interactive use with minimal effort. → [patch] use module level attribute app_label for models. Support interactive use with minimal effort.|