-6๐
You need to create two apps. first app == Group 1. second app == Group 2.
Then, you need to create proxy model in your new app. Something like this.
class ProxyReview(Review):
class Meta:
proxy = True
# If you're define ProxyReview inside review/models.py,
# its app_label is set to 'review' automatically.
# Or else comment out following line to specify it explicitly
# app_label = 'review'
# set following lines to display ProxyReview as Review
# verbose_name = Review._meta.verbose_name
# verbose_name_plural = Review._meta.verbose_name_plural
# in admin.py
admin.site.register(ProxyReview)
32๐
I do not think that splitting up your business logic, i.e. your app, when all you want to achieve is some kind of markup is the right way. Instead I found the Python package django-modeladmin-reorder that lets you achieve this easily. You can combine its feature of labelling apps and reordering models to group models of one app in the admin. After following the installation instructions, add something like this to your settings.py
ADMIN_REORDER = (
# First group
{'app': 'myapp', 'label': 'Group1',
'models': ('myapp.Model_1',
'myapp.Model_4',)
},
# Second group: same app, but different label
{'app': 'myapp', 'label': 'Group2',
'models': ('myapp.Model_2',
'myapp.Model_3',)
},)
- [Django]-Django Rest Framework How to update SerializerMethodField
- [Django]-How to get GET request values in Django Views?
- [Django]-How to render HTML in string with Javascript?
-1๐
Please make sure that your model names in ADMIN_REORDER have to be exact as written in your models.py file.
For me, it worked with Django==3.1.5 without any issue. Here is my sample code in the settings.py file
ADMIN_REORDER = (
# 'webapp',
#### First group
{
'app': 'webapp',
'label': 'group1',
'models': (
'webapp.ProductModelName_1',
'webapp.ProductModelName_2',
'webapp.ProductModelName_3',
)
},
# Second group: same app, but different label
{
'app': 'webapp',
'label': 'group2',
'models': (
'webapp.Model_X',
'webapp.Model_Y',
)
},
)
- [Django]-Django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured
- [Django]-Retrieving parameters from a URL
- [Django]-Django REST Serializer Method Writable Field