Solved

What directory structure should i set up for my Django project?

Posted on 2015-01-20
1
139 Views
Last Modified: 2015-01-21
Hi
I was wondering what the best directory structure would be for my Django project? I am only building one responsive website which will link to 3rd party APIs and use mapping. I have created a project from the command line which then created a sub directory of the same name. Should that second directory be at the same level as a new app folder that I want to create or should i put the app within that sub folder? I am getting confused since the settings.py file is in the sub directory for the project and I have no settings file in my app folder.

So is the attached correct and if so does the app folder inherit the settings from the Dango_project(n1) settings file?

thanks
0
Comment
Question by:lz7cjc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
gelonida earned 500 total points
ID: 40560837
To create a new django project:
you type
django-admin startproject mypjt

Open in new window


The directory tree will be something like this:
mypjt/
mypjt/manage.py
mypjt/mypjt
mypjt/mypjt/wsgi.py
mypjt/mypjt/__init__.py
mypjt/mypjt/urls.py
mypjt/mypjt/settings.py

Open in new window


mypjt/ will be the path for your entire django project and will also contain the script manage.py, which you shall use for any further activities concerning this project.

mypjt/ will also be the directory to put in your pythonpath. imports will be relative to that path.

mypjt/mypjt/
is the directory containing all settings and the top level urls.py file you can see this as kind of the top level application.

Let's now create your django application (you could create more than one app belonging to this project if you like to,

python mypjt/manage.py startapp myapp

Open in new window

Alternatively you could type.
cd mypjt
 python manage.py startapp myapp 

Open in new window


the directory tree looks now:
mypjt/
mypjt/manage.py
mypjt/mypjt
mypjt/mypjt/wsgi.py
mypjt/mypjt/__init__.py
mypjt/mypjt/settings.pyc
mypjt/mypjt/__init__.pyc
mypjt/mypjt/urls.py
mypjt/mypjt/settings.py

Open in new window


you see that your django application is now located  in mypjt/myapp.

This is the default directory structure for django 1.4 (and I think also for some newer versions)
the structure for django 1.3 was different.


Hope that helps
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Very easy way to crop and resize image with html 7 69
Merge XML files using a unique key? 8 144
Code Igniter Syntax question 2 133
Where to download python requests library 6 109
"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question