Best way to organize custom admin views?

34 views
Skip to first unread message

Jay

unread,
Nov 22, 2019, 2:04:41 PM11/22/19
to Django users
What's the best way (or the standard way, or your preferred way) to organize custom admin views? Assuming we want to leave the built-in Django Admin in place and create entirely new admin views, would the optimal organization be:

A new app?
blogapp/
  views
.py
  viewsets
.py
  models
.py
shoppingapp
/
  views
.py
  viewsets
.py
  models
.py
adminapp
/
  views
.py
  viewsets.py
  models
.py


Directories within each app?
blogapp/
  admin/
    views
.py
    viewsets
.py
    models
.py
shoppingapp/
  admin/
    views
.py
    viewsets
.py
    models.py


A flat structure?
blogapp/
  admin_views.py
  admin_viewsets
.py
  admin_models
.py
  views.py
  viewsets
.py
  models
.py
shoppingapp/
  admin_views.py
  admin_viewsets
.py
  admin_models
.py
  views.py
  viewsets
.py
  models.py


Something else altogether?

It’s usually not worth it to heavily customize the Django admin. Sometimes, creating a simple view or form from scratch results in the same desired functionality with a lot less work. We’ve always had better results with creating custom management dashboards for client projects than we have with modifying the admin to fit the need of the client.”
Excerpt From: Daniel Roy Greenfeld. “Two Scoops of Django 1.11.”


Wim Olivier

unread,
Nov 25, 2019, 3:53:57 AM11/25/19
to Django users
Hi,

I'd recommend using seperate apps for custom admin areas (1 app for each), and implementing a middleware that allows access to the relevant admin based on roles/permissions, etc.
It's simple, kept seperate from other code/apps nicely, and easy to limit access to different groups.

blogapp/
blogappadmin/
hrapp/
hrappadmin/


Regards,
Wim
Reply all
Reply to author
Forward
0 new messages