gath
gath

Reputation: 25492

Which function in django creates a HttpRequest instance and hands to a view?

Am try to understand the guts of django, and i cant get any good tutorial on this.

I know django views receive a HttpRequest instance as one of the arguments when they are called, what i would like to know is what function in django internals receive the request from the browser, creates the HttpRequest instance and hands it over to the right view?

Hope am clear!

Gath.

Upvotes: 11

Views: 7282

Answers (2)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799190

django.core.handlers.base.BaseHandler is responsible for sending the request through the middleware and then on to the view. The concrete handlers in django.core.handlers are what actually generate the request object in the first place.

Upvotes: 6

culebrón
culebrón

Reputation: 36513

>>> from django.http import HttpRequest
>>> HttpRequest()
<HttpRequest
GET:{},
POST:{},
COOKIES:{},
META:{}>

If you need this for testing and emulating requests, that's fine, but if you try to use this to call views from one another, it's inefficient.

Upvotes: 8

Related Questions