When and why to use Django development server?
I understand that it's simple and doesn't require any installation whatsoever, but are there any other reasons to use it for long-term development instead of Apache with mod_wsgi? As a Django newbie, I just find deployment from development to live (Apache) environment quite cumbersome and annoying, so the question that comes into my mind is: Isn't it simpler to just use mod_wsgi on localhost too? Only mention开发者_开发百科 about this in Django manual I found was:
We've included this with Django so you can develop things rapidly, without having to deal with configuring a production server -- such as Apache -- until you're ready for production.
You sometimes need the production setup locally when you're developing. I've needed it when I was messing with some subdomain related code that tied into the application and needed to mimic my real server locally.
However, for most things, the dev server is a big win. Here are a few points.
- Like rebus mentioned, the auto restart.
- Tracebacks on the console and useful debugging information.
- You can stick
pdb.set_trace()
into parts of your code and get a debugger prompt while a view method is executing if you want to look at stuff. - The entire stack runs as a single user (you) which you have complete control over.
- One command to start and run.
These come with a price which is reduced performance and inability to handle real life traffic. That's why you need a real web server to run it in production.
When I create a simple Django app for local users to populate data into a DB i usually leave it running with the development server. I've never had any problems... If it's in a local server and not exposed to the internet it should be ok to use it.
精彩评论