[Django] #21622: Support consistent customization of app_label

4 views
Skip to first unread message

Django

unread,
Dec 15, 2013, 4:51:16 PM12/15/13
to django-...@googlegroups.com
#21622: Support consistent customization of app_label
-------------------------------+--------------------
Reporter: Cerin | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------
The app_label model meta attribute effects how both a table's name appears
in the database as well as how the app's name appears in admin. Currently,
it's very difficult to separate the "logical" usage of app_label from the
"aesthetic" usage, the way we can with the db_table and verbose_name meta
attributes for individual model names.

An example of when we might want to do this is when we want to create a
django package where a non-Django package already exists. e.g. Say we want
to create an admin interface for managing RSS feeds and call it
"djangofeeds" but there's already a Python package called "feeds". We'd
want the app_label to mirror the logical Python package name, but have it
appear in admin as simply "Feeds" for clarity.

Another example when this would be useful is for renaming of the aesthetic
appearance of an existing app without effecting the database. Currently,
if you change app_label on an app with existing data, this also changes
all the names of your tables, causing South migrations to delete your old
tables along with all your data.

A partial solution to this problem is to use a class that overrides
str.title, like:

{{{

class StringWithTitle(str):
"""
String class with a title method. Can be used to override
admin app names.

http://ionelmc.wordpress.com/2011/06/24/custom-app-names-in-the-
django-admin/
"""

def __new__(cls, value, title):
instance = str.__new__(cls, value)
instance._title = title
return instance

def title(self):
return self._title

__copy__ = lambda self: self
__deepcopy__ = lambda self, memodict: self

class MyModel(models.Model):

<columns>

class Meta:
app_label = StringWithTitle('my_app_label', 'My Fancy App
Label')

}}}

However, in order for this to work everywhere in admin, all renderings of
app_label would have to call title(). Unfortunately, admin renders
app_labels inconsistently. In many places it calls title() but in others
it calls capfirst().

If all renderings of app_label used title(), this would resolve the
problem, and it would be a very simple alternative solution to ticket
https://code.djangoproject.com/ticket/3591.

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

Django

unread,
Dec 15, 2013, 5:20:02 PM12/15/13
to django-...@googlegroups.com
#21622: Support consistent customization of app_label
-------------------------------+--------------------------------------

Reporter: Cerin | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

Submitted pull request https://github.com/django/django/pull/2080
implementing this change.

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

Django

unread,
Dec 16, 2013, 2:01:46 AM12/16/13
to django-...@googlegroups.com
#21622: Support consistent customization of app_label
-------------------------------+--------------------------------------
Reporter: Cerin | Owner: nobody
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

Duplicate of #3591 - which is once again being actively worked on again
with a more narrow focus just a few things - this being one of main ones.

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

Reply all
Reply to author
Forward
0 new messages