3

In django admin, I realize that my table names are rather ugly and not user friendly. Is there a way that I can add some type of alternative name that would appear in the admin instead of the real name?

Something like ulgy_table_name -- alt name = Better looking name

user3806832
  • 663
  • 9
  • 22
  • possible duplicate of [Verbose name for admin model Class in django](http://stackoverflow.com/questions/5959462/verbose-name-for-admin-model-class-in-django) – alecxe Aug 14 '14 at 04:31
  • possible duplicate of [Can you give a Django app a verbose name for use throughout the admin?](http://stackoverflow.com/questions/612372/can-you-give-a-django-app-a-verbose-name-for-use-throughout-the-admin) – stderr Aug 14 '14 at 04:31
  • 1
    Isnt verbose name just for fields? I want something like that for the table name – user3806832 Aug 14 '14 at 05:45

2 Answers2

3
class User(models.Model):
    field_name = models.CharField(max_length=50, verbose_name = 'Better looking name')

Edited : If you wan to change the table name in admin try below

class MyModel(models.Model):
    pass
    class Meta:
        app_label = 'my_app_name'

Note :

You need to have an app in INSTALLED_APPS that matches your app_label or your tables won't get created.

Raja Simon
  • 10,126
  • 5
  • 43
  • 74
2

You don't really have to change the table names (by changing the model names) if you don't want to. You can change define it either on the Model itself or on the ModelAdmin in your admin.py. Just override the verbose_name and verbose_name_plural in their Meta options

class ... (...):
   class Meta:
       verbose_name = 'readable'
       verbose_name_plural = 'readables'

etc.

tr33hous
  • 1,622
  • 1
  • 15
  • 26
  • Is it possible to display the custom table name(i.e=> db_table) in admin page instead of using the class name which is declared in models.py. – Raja Simon Aug 14 '14 at 08:15
  • you'd have to find a way to set the `verbose_name` to `db_table`'s value – tr33hous Aug 14 '14 at 09:48