user427165
user427165

Reputation:

Django middleware using Django models?

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

Answers (2)

Ahsan
Ahsan

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

Marcin
Marcin

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

Related Questions