Reputation: 6362
I'm new to django and am coming from the MAMP and PHP world. How do you setup virtual hosts in django for a site? For example, when you run the server, instead of going to 127.0.0.1:8000, I'd like to go to mysite.dev locally? I keep reading about wsgi for Apache, but am unsure if this is the easiest way.
Basically, how do you setup virtual hosts for django? Any links or code is appreciated!
Upvotes: 0
Views: 495
Reputation: 599550
I'm not sure why you would want to do this in development. The dev server doesn't manage anything like that, it just listens to the port you tell it to and runs Django code in response. That means you can just hack your hosts
file to tell it that mysite.dev
maps to localhost. You'd still need to access port 8000 though - unless you tell runserver to bind to port 80, for which you'll need to use sudo
.
Alternatively, as you say you can set up Apache with mod_wsgi as if it were a production server - but then you'll lose the automatic code reloading, and will have to restart Apache after every change to your Python code (although there are ways around this, see the mod_wsgi documentation).
Seems like a lot of bother for almost no gain.
Upvotes: 2
Reputation: 174624
Keep in mind that unlike PHP, you don't need Apache and virtual hosts to develop and test django applications as django comes with a built-in development server.
You would only need Apache when you are ready to deploy your application, and to set that up you should read how to deploy with wsgi.
Upvotes: 2