Reputation: 1260
Is it possible to group models from different apps into 1 admin block?
For example, my structure is
project/
review/
models.py - class Review(models.Model):
followers/
models.py - class Followers(models.Model):
admin.py
In followers/admin.py
, I call
admin.site.register(Followers)
admin.site.register(Review)
This is to group them inside 1 admin block for administrators to find things easily.
I tried that, but Review
model isn't showing up inside Followers
admin block and I couldn't find documentation about this.
Upvotes: 25
Views: 8052
Reputation: 23871
Django Admin groups Models to admin block by their apps which is defined by Model._meta.app_label
. Thus registering Review
in followers/admin.py
still gets it to app review
.
So make a proxy model of Review
and put it in the 'review' app
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)
Also, you could put Followers
and Review
to same app or set same app_label
for them.
Customize admin view or use 3rd-part dashboard may achieve the goal also.
Upvotes: 46