jrief / django-angular

Let AngularJS play well with Django
http://django-angular.awesto.com/
MIT License
1.23k stars 294 forks source link

New request attributes in DjangularUrlMiddleware #223

Closed null-none closed 8 years ago

null-none commented 8 years ago

After creating new_request in djangular/middleware.py, attributes user and session (at least) are lost. A new request is created and these attributes are dropped. We should kept user and session for correct use (especially with multiple middlewares).

new_request = WSGIRequest(request.environ)
adrienbrunet commented 8 years ago

I commented on your PR. Tests are failing right now. This can't be merged.

jkosir commented 8 years ago

Well the middleware in fact does remove session and user data, along with some other attributes I suppose. Not sure how this went unnoticed for so long. Will be fixed asap.

adrienbrunet commented 8 years ago

:+1:

jkosir commented 8 years ago

Well actually user and session attributes are added in Session and Authenticaton middlewares. So if you use DjangularMiddleware correctly (first in MIDDLEWARE_CLASSES - that's what you are doing wrong) everyting works properly.

Either way I'd merge the new version of request building, since it's more robust and future-proof. Also I added code to remove djng_url_kwargs from query string.