jrief / django-angular

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

Question: wouldn't .ajax(request) be better as middleware or view mixin? #269

Closed racitup closed 7 years ago

racitup commented 7 years ago

I've been scratching my head for hours trying to figure out why my ajax json data submitted by a djng form to my native django CBV doesn't appear in the request.POST dict. It turns out I had not scrolled down far enough in the example to see the .ajax() method :-(

In any case having found this article, wouldn't this be better as a middleware like AngularUrlMiddleware?

Frankly I think it's an oversight that django provides an is_ajax method, but doesn't decode json request.body content into the POST dict or mention anything about it here.

jrief commented 7 years ago

But nowadays, native JSON is much more convenient and REST interfaces use it both ways. In my opinion, the QueryDict is a fossil from an epoch, when browsers communicated with multipart/form-data. django-shop and django-angular always use native JSON when communication through ajax, and I strongly believe that this will become the standard in the future. Therefore I strongly oppose the introduction of such a middleware.