This post describes how to deploy django application under sub-url of web site and serve it behing nginx frontend.
There are many different ways to serve python application. This article will touch configuration of only one of them: uwsgi – lightweight application server, which can serve WSGI applications.
What is covered in this post:
- preparing python environment
- configuring django applicaiton for sub-url deployment
- preparing django application for uwsgi
- configuring nginx
- starting application
What is not covered in this post:
- installing django framework
- installing uwsgi
- installing nginx
Tested on: django v.1.2, uwsgi 0.9.7.1 with this patch, nginx 0.8.54.
Python virtual environment installed at /opt/python-django-app
Django application deployed at /htdocs/my-django-app
I am playing with django-piston for last week or so, and find it simple and nice in most cases I have tried.
I had spent some time though yesterday while trying to return properly rendered django forms validation messages.
I have found couple of solutions, which are fine of course, but one of them had response formats hard coded and actually required piston patching, which I do not want to do, because prefer to stick to official releases, and another one implemented only json rendering, hard coded as well.
Links to the solutions I have found, by the way:
Getting piston forms to play nicely with JSON
django-piston form validation — part 3
So, I basically combined these solutions and investigated a bit piston sources to find how emitters are used in response rendering. I am publishing it here in hope it will be useful for other people, and if so, I will fork piston and send a merge request to master repository. The main benefit of this solution is that it re-uses emitters, so response will be renderer in corresponding format.
One point to mention, this fix assumes write-enabled part of the api is protected with authentication, which is quite reasonable expectation.
This was tested on django-piston 0.2.3.rc1 version.

