Reputation:
I created 'frontend'
application using ./manage.py startproject frontend
.
But for some reason I just want to change the app name in the Django admin to display 'Your Home Page'
instead of 'frontend'
.
How to do that?
Update: Here is the little more detail:
# "settings.py"
INSTALLED_APPS = (
'frontend',
)
And:
# "frontend/models.py"
class Newpage(models.Model):
# field here
class Oldpage(models.Model):
#field here
Upvotes: 39
Views: 52391
Reputation: 1
For example, if app name is store
, then add verbose_name with my store
to store/apps.py
as shown below:
# "store/apps.py"
from django.apps import AppConfig
class StoreConfig(AppConfig):
name = 'store'
verbose_name = "my store" # Here
Then, add the code below to "store/init.py":
# "store/__init__.py"
default_app_config = 'store.apps.StoreConfig'
Now, the app name store
is changed to my store
as shown below:
Upvotes: 4
Reputation: 1086
in django 3.0+ you just need to change the folder name and inside the apps.py change the "name" inside the "(appname)Config" class to the new name.
Upvotes: 0
Reputation: 1061
Yes, you can do it simply
in your apps.py file from your app folder change the verbose_name attribute from your config class. For example:
from django.apps import AppConfig
class FrontendConfig(AppConfig):
name = 'frontend'
verbose_name = "Your Home Page"
I test it and works in Django 1.10
UPDATE:
In Django 3+ you should add this in your __init__.py
file (from your app)
default_app_config = 'frontend.apps.FrontendConfig'
Upvotes: 64
Reputation: 123
apps.py
from django.apps import AppConfig
class FrontendConfig(AppConfig):
name = 'frontend'
verbose_name = "Your Home Page"
__ init__.py
default_app_config = 'frontend.apps.FrontendConfig'
https://docs.djangoproject.com/en/2.2/ref/applications/
Upvotes: 8
Reputation: 131
I am late but just to add an additional step to the solution explained by @FACode.
From the offical docs:
from django.apps import AppConfig
class FrontendConfig(AppConfig):
name = 'frontend'
verbose_name = "Your Home Page"
INSTALLED_APPS = [
'frontend.apps.FrontendConfig',
# ...
]
Upvotes: 8
Reputation: 118
In Django 2 we can use verbose_name in apps.py but we have to specify the CLass Config in init.py
Upvotes: 1
Reputation: 49
from django.apps import AppConfig
class AccountConfig(AppConfig):
name = 'app name'
verbose_name = "new app name"
Upvotes: 3
Reputation: 9457
In stars/app.py
from django.apps import AppConfig
class RequestsConfig(AppConfig):
name = 'stars'
verbose_name = "Star of India"
in stars/init.py
default_app_config = 'stars.apps.RequestsConfig'
To access the app name in custom menu methods you can try to get that from
model._meta.app_config.verbose_name
Check the Django Doc for reference https://docs.djangoproject.com/en/1.11/ref/applications/#for-application-users
Upvotes: 18
Reputation: 17229
It sounds like you are trying to change how the appname is listed within the Django Admin? This wasn't 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
Upvotes: 2
Reputation: 4292
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):
Upvotes: 4