Hacker News new | past | comments | ask | show | jobs | submit login

Not a single mention of AJAX.



Writing the server side of an AJAXy search was pretty straightforward. In your view function, Instead of rendering a template, you call json.dumps() (or the equivalent in XML), and set the content type of the HTTP response (i think "application/json"). Django won't generate your client side JavaScript for you (nor should it IMO), so use jQuery or whatever you want.


good point! django doesnt have any built in http resposnes or decorators for returning json (as far as i know anyways). I would recommend looking at these two options:

https://github.com/clutchio/clutch/blob/master/django_ext/ht...

https://github.com/samuelclay/NewsBlur/blob/master/utils/jso...


Why is this an issue with an article about writing effective django?


Many web apps/services now use at least a little AJAX. Certain things in a framework can make it easier. Some discussion of how AJAX techniques, up through 'single-page apps', can use a DJango back-end would be nice. (Maybe not absolutely necessary... but nice.)


Return JSON. The end.


Then, a bit of docs about the JSON apis to use, and caveats/gotchas in using them with Django Models would be helpful. The popular Django extension TastyPie could be discussed, as well as URL schemes compatible with common client-side libraries.

Similarly, ways to mimic single-page-app URLs from the server side, for first-load speed or SEO benefits, could be discussed.


What is a JSON api? Anyway, your entire wish list is out of the scope of the document. If you want to know how to build a hypermedia API (which I think is what you meant by json api) what does that have to do with "effective Django"? That would be "building effective hypermedia APIs using Django".


A JSON API is the methods & options that are available for (de)serializing your native Python or Django objects into useful JSON.

Perhaps there's a more narrow 'scope' defined for this project, but simply from the title, it seems an 'effective' Django developer would appreciate guidance for the best ways to do AJAXy things (including, especially, RESTy web services for backing AJAXy front-ends).


AJAX is nothing more than sending and receiving data from the server to the client. That's what views do, and they are documented.

There is also an is_ajax() test in Django (not that useful) and various apps that provide REST interfaces that you'd probably want to use for bigger AJAX-y apps.


you can use Django-rest-framework ,it's good.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: