tags:

views:

664

answers:

4

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!

A: 

There's a lot to your question, so I'll try to boil it down to this:

  1. 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.

  2. There is more info available about using Apache and mod-python here: mod_python and apache setup info

  3. 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 running startproject and startapp. 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.

Rob
+1  A: 

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).

Carl Meyer
Um, Carl, with the `PythonDebug On` setting, one does not need to restart Apache at all. Works like a treat during development.
ayaz
Oh, good point. Guess I never tried that. Thanks!
Carl Meyer
+1  A: 

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.

A: 

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.

Mike Biglan