Reputation:
Is it possible to use regular Django models from within Middleware?
I have been looking for simple examples but couldn't find anything about the availability of such parts of the Django framework to middleware. I believe from my limited understanding that they should be.
Upvotes: 0
Views: 856
Reputation: 11832
Yes, i agree with @marcin you can use models anywhere, and as a reference you can look at django flatpages middleware, there it took the decision which flatpage
should be rendered.
Upvotes: 0
Reputation: 49886
The model system is available from everywhere in your django application, as long as you import the relevant models. It is not tied to the HTTP lifecycle.
Upvotes: 6