Hi devs,
I have a weird problem that I first thought is on my side. But after
thinking about it, it could be fixed in Django with a no-brainer and
backwards-compatible. But before filing a bug, I'd like to ask here for
your opinion - it may be that I am stil wrong.
I use a custom view mixin class that is used for some views in my
application, and it is also an interface for a plugin system, so it will
be loaded at **declaration time** (before apps & models are loaded).
All good so far, but nearly all of my views need django's
PermissionRequiredMixin. So I decided to add PermissionRequiredMixin
directly to my parent mixin class (which gets loaded early). Neither my
class nor PermissionRequiredMixin uses models, but just by loading
`django.contrib.auth.mixins` there is one line that hickups Django:
from django.contrib.auth.viewsimport redirect_to_login
This leads to importing "User", hence a model, and Django throws a
AppRegistryNotReady exception.
In django.contrib.auth.mixins, the only method that uses
"redirect_to_login()" is line 60 in handle_no_permission().
This "problem" could be easily solved if the import statement is done
locally in handle_no_permission, and not at module level - which leads
to the django.contrib.auth.mixins being usable in early Django (before
model loading).
The only side effect I could think of, that it adds some loading time
during that method call the first time - but reduces the same loading
time at startup. Which is neglegible IMHO.
Please tell me if I'm completely wrong - or if this is worth a bug
report/PR.
Christian
--
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/87640740-b78e-5ecf-ba2a-ef53c1ba10a7%40nerdocs.at.