#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. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/048.56269b003adacd04d8eb65e6aee14b7e%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.