Hi again.

Maybe this has been discussed before (please tell me).

In each and every Django project I start, I need the Django Admin during development to create some model data for testing.

And each and every time  I wonder why I have to add the same boilerplate code for every single model in every app.

So in most projects, I start with a generic way of adding all models to admin.py programmatically.

and after a few iterations, I thought I'll ask you if that wasn't a helpful default to add to Django itself.

* I know that there are ModelAdmins, in case you want to sort it out differently * I know that there are edge cases and abstract models that shouldn't be listed

So what if Django (admin) would add models to the admin view, if

* DEBUG==True,
* maybe another attr is present, like settings.AUTO_ADMIN_MODELS
* all admin.py files are already parsed and manually added models are included, with their special ModelAdmins

like:

# first parse all apps' admin.py

if settings.DEBUG:
    # all other models
    models = apps.get_models()

    for model in models:
        try:
            if not model._meta.abstract:
                admin.site.register(model)
        except admin.sites.AlreadyRegistered:
            pass


It would help getting started with Django more quickly.

--
Dr. Christian González
https://nerdocs.at

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/d3aba97f-42e5-72f8-5cb2-20381c1358fa%40nerdocs.at.

Reply via email to