How to change app name in Django admin?

后端 未结 8 1956
小鲜肉
小鲜肉 2020-12-14 08:03

I created \'frontend\' application using ./manage.py startproject frontend

But for some reason I just want to change the app name in the Dj

8条回答
  •  一生所求
    2020-12-14 08:33

    1.Try to add app_label to your model that will be registered in Admin.

    class MyModel(models.Model):
            pass
        class Meta:
            app_label = 'My APP name'
    

    UPDATE: 2. Steps to rename app(folders):

    • Rename the folder which is in your project root
    • Change any references to your app in their dependencies, i.e. the app's views, the urls.py and settings.py files.
    • Edit the database table django_content_type with the following command: UPDATE django_content_type SET app_label='' WHERE app_label=''
    • Also if you have models, you will have to rename the model tables. For postgres use ALTER TABLE _modelName RENAME TO _modelName. For renaming models, you'll need to change django_content_type.name Note: If your models.py 's Meta Class has app_name listed, make sure to rename that too.

提交回复
热议问题