0

I currently have 2 admin.py files.

  1. project/admin.py
  2. project/pages/basicpage/admin.py

I would like to use the registered classes inside the second admin.py along with the first admin.py such that they can both be reached at the same admin endpoint.

FILE ONE: project/admin.py

from django.contrib import admin
from project import models
from project.pages.basicpage import admin as BP_admin


@admin.register(models.Test)
class TestAdmin(admin.ModelAdmin):
    pass

FILE TWO: project/pages/basicpage/admin.py

from django.contrib import admin
from project import models

@admin.register(models.Platform)
class PlatformAdmin(admin.ModelAdmin):
    pass


@admin.register(models.Type)
class TypeAdmin(admin.ModelAdmin):
    pass

In file one, I have imported the second admin as BP_admin, not that it is used yet. However when I access my http://127.0.0.1:8000/admin endpoint, understandably I only can view the "Test" class that is registered in the first file. Any idea how to get my other 2 classes from my second file registered to the first file's endpoint?

Thanks!

ehuff
  • 89
  • 9
  • Does this answer your question? [Multiple ModelAdmins/views for same model in Django admin](https://stackoverflow.com/questions/2223375/multiple-modeladmins-views-for-same-model-in-django-admin) – Bernardo Duarte Jan 12 '21 at 22:08
  • not quite, this link allows the user to include ONE model across MULTIPLE endpoints. I want MULTIPLE models from different admin files to be routed to the SAME endpoint. – ehuff Jan 12 '21 at 22:28

1 Answers1

1

Admin is just the models so importing the models should be enough. You can just add:

from project.pages.basicpage import models as BP_models

@admin.register(models.Test)
...

@admin.register(BP_models.Platform)
class Platform(models.Platform):
    pass

You can also simplify and not use the class:

@admin.register(models.Test, BP_models.Platform,....)