4👍
Simply please create a separate App for separate model categories.
You can create app like this (settings.py
):
python manage.py startapp food
python manage.py startapp gym
python manage.py startapp farm
INSTALLED_APP += [
'farm',
'food',
'gym',
]
And in admin.py
:
admin.site.register(food)
admin.site.register(gym)
admin.site.register(farm)
This is right way.
1👍
There are two ways.
1. Customize the Django admin site.
https://docs.djangoproject.com/en/4.0/intro/tutorial07/#customize-the-admin-index-page
2. Create different apps for each categories.
In terminal,
python manage.py startapp food
python manage.py startapp gym
python manage.py startapp farm
In food/admin.py file,
admin.site.register(Food_Gallery)
In gym/admin.py file,
admin.site.register(Gym)
admin.site.register(Gym_Gallery)
admin.site.register(Gym_Pricing_Plans)
admin.site.register(Gym_Programs)
admin.site.register(Trainer)
In farm/admin.py file,
admin.site.register(Farm)
admin.site.register(Farm_Gallery)
admin.site.register(Farm_Products)
You also have to add your apps in settings.py
file and maybe you need to modify some of your code.
Each method has its pros and cons, so it is up to you which to use.
- [Django]-How to list all the files of a custom directory
- [Django]-Permission classess decorator is ignored. "Authentication credentials were not provided" response
- [Django]-Django Unknown system variable 'TRANSACTION' on syncdb
- [Django]-502 error after adding application to a Django project running on nginx and gunicorn
Source:stackexchange.com