tags:

views:

580

answers:

1

So I have a django project I just created called 'coolprojectsite' the directory structure looks something as follows:

* media (dir)
* mytemplates (dir)
* * admin (dir)
* * coolprojects (dir)
* coolprojectsite (dir)
* * coolproject (dir)
* * * __init__.py
* * * admin.py
* * * models.py
* * * tests.py
* * * urls.py
* * * views.py
* * __init__.py
* * settings.py
* * urls.py

So I have a few questions.

1) Is coolprojectsite considered the 'project'

2) Is coolproject considered the 'application'

3) 'media' contains the css, javascript files etc. Is that the proper place for them? Its outside the project.

4) 'mytemplates' has specific files that contain django markup (e.g. {% %} ) and they are accessed because my urls.py points to them. Is it proper to have these files outside the project?

5) If I want to include some arbitrary javascript file (say jquery) do I just create a new entry in urls.py (if so, should it be the one in coolprojectsite, or coolproject) and then link to that url?

+5  A: 
  1. "Project" is not really a useful concept in Django. The Django tutorial mentions it, but the developers have frequently mentioned on mailing lists that they wish they hadn't introduced it. Basically, a project is just a container for your code - but in fact the code can live anywhere on the Pythonpath.

  2. Yes, and you can have multiple applications as long as they're all added to INSTALLED_APPS in settings.py.

  3. It doesn't matter where they live. You will need something to serve them - in development, it can be done with the built-in server, but in production you'll need to point Apache (or whatever) directly at the files.

  4. Doesn't matter. It's the views that load the templates, and again as long as TEMPLATE_DIRS is set properly in settings.py that's fine.

  5. No, absolutely not. As mentioned, static assets live in your media folder, and don't get served through Django.

Daniel Roseman
Personally, I do find "project" to be a useful concept. Projects are what I generally work on, after all - that's the deliverable. So I keep my static assets directory and my template directory in a directory with settings files, root URLconf, oftentimes a few one-off project-specific apps, put it all under version control and call it "the project". I don't think there's anything wrong with that. The key thing is to realize that there's nothing "magic" in Django about a certain directory, you can arrange things pretty much however suits your workflow and make it work.
Carl Meyer