How to change application name in Django admin?

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

But for some reason, I just want to change the application name in the Django admin to display 'Your Home Page' instead of 'frontend' .

How to do it?

Update: Here is a little more detail:

 #settings.py INSTALLED_APPS = ( 'frontend', ) 

and

 #frontend/models.py class Newpage(models.Model): #field here class Oldpage(models.Model): #field here 
+11
source share
7 answers

Yes you can do it just

in your apps.py file from the application folder, change the verbose_name attribute from your configuration class. For instance:

 from django.apps import AppConfig class FrontendConfig(AppConfig): name = 'frontend' verbose_name = "Your Home Page" 

I test it and work in Django 1.10

+14
source

In the stars /app.py

 from django.apps import AppConfig class RequestsConfig(AppConfig): name = 'stars' verbose_name = "Star of India" 

in the stars / init .py

 default_app_config = 'stars.apps.RequestsConfig' 

To access the application name in custom menu methods, you can try to get it from

 model._meta.app_config.verbose_name 

Check out the Django Doc for the link https://docs.djangoproject.com/en/1.11/ref/applications/#for-application-users

+3
source

1. Try adding app_label to your model, which will be registered in Admin.

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

UPDATE: 2. Steps to rename an application (folder):

  • Rename the folder located in the root directory of the project
  • Change any links to your application in your dependencies, i.e. in applications, urls.py and settings.py files.
  • Edit the django_content_type database table 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. To rename models you need to change django_content_type.name Note. If your metadata models.py Meta Class contains the name of the application, be sure to rename it.
+2
source

Looks like you're trying to change the way you add the application name in Django Admin? This was not possible before Django 1.7, but now you can do it like this:

https://docs.djangoproject.com/en/1.7/ref/applications/#for-application-users

+2
source

In apps.py

  from django.apps import AppConfig class AccountConfig(AppConfig): name = 'app name' verbose_name = "new app name" 
0
source

In Django 2, we can use verbose_name in apps.py, but we need to specify the CLass configuration in init .py

See the relevant document here.

0
source

I was late, but just added another step to the solution explained by @ FACode .
From official docs :

In frontend / apps.py

 from django.apps import AppConfig class FrontendConfig(AppConfig): name = 'frontend' verbose_name = "Your Home Page" 

In app / settings.py

  INSTALLED_APPS = [ 'frontend.apps.FrontendConfig', # ... ] 
0
source

Source: https://habr.com/ru/post/978276/


All Articles