I'm dying to get started Django but I'm really struggling with the initial setup. I have Python/MySql/Apache2.2/mod_python installed. Now I'm trying to create a proper directory structure and then update Django and Apache settings.py/httpd docs respectively. Specifically the location tag in the latter. Django and Python are based on simplicity but this is one huge oversight from the Django folks to not provide more guidance in this area. I had a basic page running in the Django dev server but could not get the stylesheet to load. So i decided to install mod_python and try to use apache in my dev environment and I'm even more frustrated. I can't seem find a good example anywhere on the web or in books regarding how to create a realistic directory structure and then based on that strucure, how to configure neccessary settings. Everything in tutorials is as usual not realistic or very helpful. Too simple. If someone here could share how they have their Django directory and settings configured that would be FANTASTIC!
There's a lot to your question, so I'll try to boil it down to this:
The tutorial is aimed at getting you to use the framework and to be up and running with as little configuration as possible. No server to configure, etc. If you are trying to load CSS with the dev server, you will need to pull the CSS from somewhere "beyond" the dev server. For example, on my Mac, I launch the dev server, but load the CSS from the built-in apache server.
There is more info available about using Apache and mod-python here: mod_python and apache setup info
I'm not sure what you mean by "creating the directory structure", but most of the core application files are typically created by running the
django-admin.py
script, by runningstartproject
andstartapp
. This is demonstrated in the tutorial.
You can also ask questions on the IRC #django channel! If you are looking for a book on the subject, you can also check out the Django Book.
Don't use Apache for development, that'll make you tear your hair out restarting Apache every fifteen seconds (EDIT: or you could just use PythonDebug On).
This technique is how to get your media (stylesheets, etc) loading via the development server. If you used that exact snippet, you'd need to set MEDIA_URL to '/site_media/' and MEDIA_ROOT to '/path/to/media' (obviously this latter is likely to need changing to wherever your media files actually are).
Thanks guys. After doing some more searching I found exactly what i was looking for here. It's an example project directory structure and settings.py. If you view the comments there you can see a lot of others were confused about this as well and found the example helpful. It would be nice if Django created a recommended dir structure so you know where to store css, js, django app files, template files, etc.
We just built and released (under Apache2) Djenesis at OSCON2010:
The two goals of Djenesis are to
- ease bootstrapping new projects based on your
- provide a default project template based on dozens of Django-based, web-specific applications
More details about the features/benefits/tutorial as well as the code are on Google Code.