Django: how to startapp inside an "apps" folder - django

I feel like I must be looking over something obvious because I am having trouble finding anything online about this. But basically here it is, I have a django Project, and I would like to store my apps inside of an apps folder, like thus...
myproject/
client-side/
media/
static/
templates/
apps/
app1/
app2/
etc.
__init__.py
manage.py
etc. (rest of root directory)
but have been unable to figure out how to >>>python manage.py startapp newapp and have it placed into the /apps/ folder. Is it ok to simply ok to startapp at the root level and manually move them into the /apps/ folder?
I greatly appreciate your thoughts and answers.
FYI running python 3.4.2 and Django 1.9.5 on Windows 10

You can specify the app's directory as a second parameter:
python manage.py startapp <app_name> <app_directory>
Note that no directory will be created, the app's files will be created directly in the specified directory. Example:
python manage.py startapp myapp apps/myapp
Will result in the given directory structure:
apps
└── myapp
├── __init__.py
├── admin.py
├── apps.py
├── migrations
│   └── __init__.py
├── models.py
├── tests.py
└── views.py
Also note that the command won't create the directory for you.
Edit: as another (now deleted) answer pointed out, running the command from the apps directory would also work:
cd apps
python ../manage.py startapp myapp

You can also use the django-admin command as well.
cd apps && django-admin startapp app_1
this will work as well

Related

ModuleNotFound error Django and Heroku deployment

I am new to Django and to programming overall, and I am trying to deploy my personal website developed with Django to heroku.
I feel like I am at the last step but one error keeps bugging me and I cannot solve it on my own or with documentation.
My project folders are like this:
enter image description here
My Procfile:
enter image description here
My wsgi file:
enter image description here
And in the heroku logs I get the following:
2020-01-04T15:45:47.211072+00:00 app[web.1]: ModuleNotFoundError: No module named 'blog'
There are many blue lines but I believe this is the one that is problematic (i.e. not being able to find the settings file from this)
Is there anything else I can provide if this is not clear?
Thanks for any help
I welcome any questions
UPDATE!
So, I updated the db I use from SQLite3 to PostgreSQL and I still get a Server Error 500.
Here is my manage.py where I put the PostgreSQL:
DATABASE in manage.py
The app runs when I do manage.py runserver but it does not when heroku deploys it.
The heroku log looks like this:
heroku log
To summarise the process of investigating startup problems. There were two issues:
1. The project layout was different for local development and for production on heroku whereas the codebase was set up for highest level mysite as a homepath except wsgi.py file what caused spending extra time on troubleshooting.
.
├── Procfile <- web: gunicorn mysite.mysite.wsgi
├── mysite
│   ├── __init__.py
│   ├── blog
│   ├── db.sqlite3
│   ├── manage.py <- python manage.py runserver
│   ├── mysite
│   ├── static
│   ├── staticfiles
│   └── templates
├── requirements.txt
└── venv
Solution:
Fix codebase for mysite as a homepath and run gunicorn with either --chdir or --pythonpath setting to have a proper path settings for gunicorn.
--chdir: Chdir to specified directory before apps loading:
web: gunicorn --chdir mysite mysite.wsgi
--pythonpath: Add directories to the Python path
web: gunicorn --pythonpath mysite mysite.wsgi
2. Migrations. There wasn't any migration applying action.
Solution:
Adding release phase to Procfile which will apply migrations every time the app is deployed:
release: cd mysite && python manage.py migrate
After solving these two issues the app got up and running.

Django and Collectstatic Issue

I'm trying to deploy my Django web Application (2.0.1) thanks to Nginx and I'm getting an issue.
I configured the new Ubuntu server, add my Django Project and I downloaded nginx.
My Django project looks like :
Mysite
├── App1
├── App2
├── App3
├── lib
├── Global_variables.py
├── Mysite
├── settings.py
I have to make collectstatic with nginx, so I execute this command :
python manage.py collectstatic
But into my settings.py file, I have :
#from django.conf import global_settings
import os, datetime
import lib.Global_variables
And this issue :
File "/var/www/Mysite/Mysite/settings.py", line 16, in <module>
import lib.Global_variables
ImportError: No module named lib.Global_variables
However my import seems to be right. Any idea ?
To make directory a python package you need to add inside this directory __init__.py file. From the docs:
The init.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path

Ideal Architecture for Django Projects [duplicate]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I know there is actually no single right way. However I've found that it's hard to create a directory structure that works well and remain clean for every developer and administrator. There is some standard structure in most projects on github. But it does not show a way to organize another files and all projects on pc.
What is the most convenient way to organize all these directories on development machine? How do you name them, and how do you connect and deploy this to server?
projects (all projects that your are working on)
source files (the application itself)
working copy of repository (I use git)
virtual environment (I prefer to place this near the project)
static root (for compiled static files)
media root (for uploaded media files)
README
LICENSE
documents
sketches
examples (an example project that uses the application provided by this project)
database (in case sqlite is used)
anything else that you usually need for successful work on project
The problems that I want to solve:
Good names of directories so that their purpose is clear.
Keeping all project files (including virtualenv) in one place, so I can easily copy, move, archive, remove whole project or estimate disk space usage.
Creating multiple copies of some selected file sets such as entire application, repository or virtualenv, while keeping single copy of another files that I don't want to clone.
Deploying right set of files to the server simply by rsyncing selected one dir.
There're two kind of Django "projects" that I have in my ~/projects/ directory, both have a bit different structure.:
Stand-alone websites
Pluggable applications
Stand-alone website
Mostly private projects, but doesn't have to be. It usually looks like this:
~/projects/project_name/
docs/ # documentation
scripts/
manage.py # installed to PATH via setup.py
project_name/ # project dir (the one which django-admin.py creates)
apps/ # project-specific applications
accounts/ # most frequent app, with custom user model
__init__.py
...
settings/ # settings for different environments, see below
__init__.py
production.py
development.py
...
__init__.py # contains project version
urls.py
wsgi.py
static/ # site-specific static files
templates/ # site-specific templates
tests/ # site-specific tests (mostly in-browser ones)
tmp/ # excluded from git
setup.py
requirements.txt
requirements_dev.txt
pytest.ini
...
Settings
The main settings are production ones. Other files (eg. staging.py,
development.py) simply import everything from production.py and override only necessary variables.
For each environment, there are separate settings files, eg. production,
development. I some projects I have also testing (for test runner), staging
(as a check before final deploy) and heroku (for deploying to heroku) settings.
Requirements
I rather specify requirements in setup.py directly. Only those required for
development/test environment I have in requirements_dev.txt.
Some services (eg. heroku) requires to have requirements.txt in root directory.
setup.py
Useful when deploying project using setuptools. It adds manage.py to PATH, so I can run manage.py directly (anywhere).
Project-specific apps
I used to put these apps into project_name/apps/ directory and import them
using relative imports.
Templates/static/locale/tests files
I put these templates and static files into global templates/static directory, not inside each app.
These files are usually edited by people, who doesn't care about project code
structure or python at all. If you are full-stack developer working alone or
in a small team, you can create per-app templates/static directory. It's really just a matter of taste.
The same applies for locale, although sometimes it's convenient to create separate locale directory.
Tests are usually better to place inside each app, but usually there is many
integration/functional tests which tests more apps working together, so global
tests directory does make sense.
Tmp directory
There is temporary directory in project root, excluded from VCS. It's used to
store media/static files and sqlite database during development. Everything in
tmp could be deleted anytime without any problems.
Virtualenv
I prefer virtualenvwrapper and place all venvs into ~/.venvs directory,
but you could place it inside tmp/ to keep it together.
Project template
I've created project template for this setup, django-start-template
Deployment
Deployment of this project is following:
source $VENV/bin/activate
export DJANGO_SETTINGS_MODULE=project_name.settings.production
git pull
pip install -r requirements.txt
# Update database, static files, locales
manage.py syncdb --noinput
manage.py migrate
manage.py collectstatic --noinput
manage.py makemessages -a
manage.py compilemessages
# restart wsgi
touch project_name/wsgi.py
You can use rsync instead of git, but still you need to run batch of commands to update your environment.
Recently, I made django-deploy app, which allows me to run single management command to update environment, but I've used it for one project only and I'm still experimenting with it.
Sketches and drafts
Draft of templates I place inside global templates/ directory. I guess one can create folder sketches/ in project root, but haven't used it yet.
Pluggable application
These apps are usually prepared to publish as open-source. I've taken example
below from django-forme
~/projects/django-app/
docs/
app/
tests/
example_project/
LICENCE
MANIFEST.in
README.md
setup.py
pytest.ini
tox.ini
.travis.yml
...
Name of directories is clear (I hope). I put test files outside app directory,
but it really doesn't matter. It is important to provide README and setup.py, so package is easily installed through pip.
My answer is inspired on my own working experience, and mostly in the book Two Scoops of Django which I highly recommend, and where you can find a more detailed explanation of everything. I just will answer some of the points, and any improvement or correction will be welcomed. But there also can be more correct manners to achieve the same purpose.
Projects
I have a main folder in my personal directory where I maintain all the projects where I am working on.
Source Files
I personally use the django project root as repository root of my projects. But in the book is recommended to separate both things. I think that this is a better approach, so I hope to start making the change progressively on my projects.
project_repository_folder/
.gitignore
Makefile
LICENSE.rst
docs/
README.rst
requirements.txt
project_folder/
manage.py
media/
app-1/
app-2/
...
app-n/
static/
templates/
project/
__init__.py
settings/
__init__.py
base.py
dev.py
local.py
test.py
production.py
ulrs.py
wsgi.py
Repository
Git or Mercurial seem to be the most popular version control systems among Django developers. And the most popular hosting services for backups GitHub and Bitbucket.
Virtual Environment
I use virtualenv and virtualenvwrapper. After installing the second one, you need to set up your working directory. Mine is on my /home/envs directory, as it is recommended on virtualenvwrapper installation guide. But I don't think the most important thing is where is it placed. The most important thing when working with virtual environments is keeping requirements.txt file up to date.
pip freeze -l > requirements.txt
Static Root
Project folder
Media Root
Project folder
README
Repository root
LICENSE
Repository root
Documents
Repository root. This python packages can help you making easier mantaining your documentation:
reStructuredText
Sphinx
Sketches
Examples
Database
I don't like to create a new settings/ directory. I simply add files named settings_dev.py and settings_production.py so I don't have to edit the BASE_DIR.
The approach below increase the default structure instead of changing it.
mysite/ # Project
conf/
locale/
en_US/
fr_FR/
it_IT/
mysite/
__init__.py
settings.py
settings_dev.py
settings_production.py
urls.py
wsgi.py
static/
admin/
css/ # Custom back end styles
css/ # Project front end styles
fonts/
images/
js/
sass/
staticfiles/
templates/ # Project templates
includes/
footer.html
header.html
index.html
myapp/ # Application
core/
migrations/
__init__.py
templates/ # Application templates
myapp/
index.html
static/
myapp/
js/
css/
images/
__init__.py
admin.py
apps.py
forms.py
models.py
models_foo.py
models_bar.py
views.py
templatetags/ # Application with custom context processors and template tags
__init__.py
context_processors.py
templatetags/
__init__.py
templatetag_extras.py
gulpfile.js
manage.py
requirements.txt
I think this:
settings.py
settings_dev.py
settings_production.py
is better than this:
settings/__init__.py
settings/base.py
settings/dev.py
settings/production.py
This concept applies to other files as well.
I usually place node_modules/ and bower_components/ in the project directory within the default static/ folder.
Sometime a vendor/ directory for Git Submodules but usually I place them in the static/ folder.
As per the Django Project Skeleton, the proper directory structure that could be followed is :
[projectname]/ <- project root
├── [projectname]/ <- Django root
│ ├── __init__.py
│ ├── settings/
│ │ ├── common.py
│ │ ├── development.py
│ │ ├── i18n.py
│ │ ├── __init__.py
│ │ └── production.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ └── __init__.py
├── configs/
│ ├── apache2_vhost.sample
│ └── README
├── doc/
│ ├── Makefile
│ └── source/
│ └── *snap*
├── manage.py
├── README.rst
├── run/
│ ├── media/
│ │ └── README
│ ├── README
│ └── static/
│ └── README
├── static/
│ └── README
└── templates/
├── base.html
├── core
│ └── login.html
└── README
Refer https://django-project-skeleton.readthedocs.io/en/latest/structure.html for the latest directory structure.
Here is what I follow on My system.
All Projects: There is a projects directory in my home folder i.e. ~/projects. All the projects rest inside it.
Individual Project: I follow a standardized structure template used by many developers called django-skel for individual projects. It basically takes care of all your static file and media files and all.
Virtual environment: I have a virtualenvs folder inside my home to store all virtual environments in the system i.e. ~/virtualenvs . This gives me flexibility that I know what all virtual environments I have and can look use easily
The above 3 are the main partitions of My working environment.
All the other parts you mentioned are mostly dependent on project to project basis (i.e. you might use different databases for different projects). So they should reside in their individual projects.
You can use https://github.com/Mischback/django-project-skeleton repository.
Run below command:
$ django-admin startproject --template=https://github.com/Mischback/django-project-skeleton/archive/development.zip [projectname]
The structure is something like this:
[projectname]/ <- project root
├── [projectname]/ <- Django root
│ ├── __init__.py
│ ├── settings/
│ │ ├── common.py
│ │ ├── development.py
│ │ ├── i18n.py
│ │ ├── __init__.py
│ │ └── production.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ └── __init__.py
├── configs/
│ ├── apache2_vhost.sample
│ └── README
├── doc/
│ ├── Makefile
│ └── source/
│ └── *snap*
├── manage.py
├── README.rst
├── run/
│ ├── media/
│ │ └── README
│ ├── README
│ └── static/
│ └── README
├── static/
│ └── README
└── templates/
├── base.html
├── core
│ └── login.html
└── README

Best practice for Django project working directory structure [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I know there is actually no single right way. However I've found that it's hard to create a directory structure that works well and remain clean for every developer and administrator. There is some standard structure in most projects on github. But it does not show a way to organize another files and all projects on pc.
What is the most convenient way to organize all these directories on development machine? How do you name them, and how do you connect and deploy this to server?
projects (all projects that your are working on)
source files (the application itself)
working copy of repository (I use git)
virtual environment (I prefer to place this near the project)
static root (for compiled static files)
media root (for uploaded media files)
README
LICENSE
documents
sketches
examples (an example project that uses the application provided by this project)
database (in case sqlite is used)
anything else that you usually need for successful work on project
The problems that I want to solve:
Good names of directories so that their purpose is clear.
Keeping all project files (including virtualenv) in one place, so I can easily copy, move, archive, remove whole project or estimate disk space usage.
Creating multiple copies of some selected file sets such as entire application, repository or virtualenv, while keeping single copy of another files that I don't want to clone.
Deploying right set of files to the server simply by rsyncing selected one dir.
There're two kind of Django "projects" that I have in my ~/projects/ directory, both have a bit different structure.:
Stand-alone websites
Pluggable applications
Stand-alone website
Mostly private projects, but doesn't have to be. It usually looks like this:
~/projects/project_name/
docs/ # documentation
scripts/
manage.py # installed to PATH via setup.py
project_name/ # project dir (the one which django-admin.py creates)
apps/ # project-specific applications
accounts/ # most frequent app, with custom user model
__init__.py
...
settings/ # settings for different environments, see below
__init__.py
production.py
development.py
...
__init__.py # contains project version
urls.py
wsgi.py
static/ # site-specific static files
templates/ # site-specific templates
tests/ # site-specific tests (mostly in-browser ones)
tmp/ # excluded from git
setup.py
requirements.txt
requirements_dev.txt
pytest.ini
...
Settings
The main settings are production ones. Other files (eg. staging.py,
development.py) simply import everything from production.py and override only necessary variables.
For each environment, there are separate settings files, eg. production,
development. I some projects I have also testing (for test runner), staging
(as a check before final deploy) and heroku (for deploying to heroku) settings.
Requirements
I rather specify requirements in setup.py directly. Only those required for
development/test environment I have in requirements_dev.txt.
Some services (eg. heroku) requires to have requirements.txt in root directory.
setup.py
Useful when deploying project using setuptools. It adds manage.py to PATH, so I can run manage.py directly (anywhere).
Project-specific apps
I used to put these apps into project_name/apps/ directory and import them
using relative imports.
Templates/static/locale/tests files
I put these templates and static files into global templates/static directory, not inside each app.
These files are usually edited by people, who doesn't care about project code
structure or python at all. If you are full-stack developer working alone or
in a small team, you can create per-app templates/static directory. It's really just a matter of taste.
The same applies for locale, although sometimes it's convenient to create separate locale directory.
Tests are usually better to place inside each app, but usually there is many
integration/functional tests which tests more apps working together, so global
tests directory does make sense.
Tmp directory
There is temporary directory in project root, excluded from VCS. It's used to
store media/static files and sqlite database during development. Everything in
tmp could be deleted anytime without any problems.
Virtualenv
I prefer virtualenvwrapper and place all venvs into ~/.venvs directory,
but you could place it inside tmp/ to keep it together.
Project template
I've created project template for this setup, django-start-template
Deployment
Deployment of this project is following:
source $VENV/bin/activate
export DJANGO_SETTINGS_MODULE=project_name.settings.production
git pull
pip install -r requirements.txt
# Update database, static files, locales
manage.py syncdb --noinput
manage.py migrate
manage.py collectstatic --noinput
manage.py makemessages -a
manage.py compilemessages
# restart wsgi
touch project_name/wsgi.py
You can use rsync instead of git, but still you need to run batch of commands to update your environment.
Recently, I made django-deploy app, which allows me to run single management command to update environment, but I've used it for one project only and I'm still experimenting with it.
Sketches and drafts
Draft of templates I place inside global templates/ directory. I guess one can create folder sketches/ in project root, but haven't used it yet.
Pluggable application
These apps are usually prepared to publish as open-source. I've taken example
below from django-forme
~/projects/django-app/
docs/
app/
tests/
example_project/
LICENCE
MANIFEST.in
README.md
setup.py
pytest.ini
tox.ini
.travis.yml
...
Name of directories is clear (I hope). I put test files outside app directory,
but it really doesn't matter. It is important to provide README and setup.py, so package is easily installed through pip.
My answer is inspired on my own working experience, and mostly in the book Two Scoops of Django which I highly recommend, and where you can find a more detailed explanation of everything. I just will answer some of the points, and any improvement or correction will be welcomed. But there also can be more correct manners to achieve the same purpose.
Projects
I have a main folder in my personal directory where I maintain all the projects where I am working on.
Source Files
I personally use the django project root as repository root of my projects. But in the book is recommended to separate both things. I think that this is a better approach, so I hope to start making the change progressively on my projects.
project_repository_folder/
.gitignore
Makefile
LICENSE.rst
docs/
README.rst
requirements.txt
project_folder/
manage.py
media/
app-1/
app-2/
...
app-n/
static/
templates/
project/
__init__.py
settings/
__init__.py
base.py
dev.py
local.py
test.py
production.py
ulrs.py
wsgi.py
Repository
Git or Mercurial seem to be the most popular version control systems among Django developers. And the most popular hosting services for backups GitHub and Bitbucket.
Virtual Environment
I use virtualenv and virtualenvwrapper. After installing the second one, you need to set up your working directory. Mine is on my /home/envs directory, as it is recommended on virtualenvwrapper installation guide. But I don't think the most important thing is where is it placed. The most important thing when working with virtual environments is keeping requirements.txt file up to date.
pip freeze -l > requirements.txt
Static Root
Project folder
Media Root
Project folder
README
Repository root
LICENSE
Repository root
Documents
Repository root. This python packages can help you making easier mantaining your documentation:
reStructuredText
Sphinx
Sketches
Examples
Database
I don't like to create a new settings/ directory. I simply add files named settings_dev.py and settings_production.py so I don't have to edit the BASE_DIR.
The approach below increase the default structure instead of changing it.
mysite/ # Project
conf/
locale/
en_US/
fr_FR/
it_IT/
mysite/
__init__.py
settings.py
settings_dev.py
settings_production.py
urls.py
wsgi.py
static/
admin/
css/ # Custom back end styles
css/ # Project front end styles
fonts/
images/
js/
sass/
staticfiles/
templates/ # Project templates
includes/
footer.html
header.html
index.html
myapp/ # Application
core/
migrations/
__init__.py
templates/ # Application templates
myapp/
index.html
static/
myapp/
js/
css/
images/
__init__.py
admin.py
apps.py
forms.py
models.py
models_foo.py
models_bar.py
views.py
templatetags/ # Application with custom context processors and template tags
__init__.py
context_processors.py
templatetags/
__init__.py
templatetag_extras.py
gulpfile.js
manage.py
requirements.txt
I think this:
settings.py
settings_dev.py
settings_production.py
is better than this:
settings/__init__.py
settings/base.py
settings/dev.py
settings/production.py
This concept applies to other files as well.
I usually place node_modules/ and bower_components/ in the project directory within the default static/ folder.
Sometime a vendor/ directory for Git Submodules but usually I place them in the static/ folder.
As per the Django Project Skeleton, the proper directory structure that could be followed is :
[projectname]/ <- project root
├── [projectname]/ <- Django root
│ ├── __init__.py
│ ├── settings/
│ │ ├── common.py
│ │ ├── development.py
│ │ ├── i18n.py
│ │ ├── __init__.py
│ │ └── production.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ └── __init__.py
├── configs/
│ ├── apache2_vhost.sample
│ └── README
├── doc/
│ ├── Makefile
│ └── source/
│ └── *snap*
├── manage.py
├── README.rst
├── run/
│ ├── media/
│ │ └── README
│ ├── README
│ └── static/
│ └── README
├── static/
│ └── README
└── templates/
├── base.html
├── core
│ └── login.html
└── README
Refer https://django-project-skeleton.readthedocs.io/en/latest/structure.html for the latest directory structure.
Here is what I follow on My system.
All Projects: There is a projects directory in my home folder i.e. ~/projects. All the projects rest inside it.
Individual Project: I follow a standardized structure template used by many developers called django-skel for individual projects. It basically takes care of all your static file and media files and all.
Virtual environment: I have a virtualenvs folder inside my home to store all virtual environments in the system i.e. ~/virtualenvs . This gives me flexibility that I know what all virtual environments I have and can look use easily
The above 3 are the main partitions of My working environment.
All the other parts you mentioned are mostly dependent on project to project basis (i.e. you might use different databases for different projects). So they should reside in their individual projects.
You can use https://github.com/Mischback/django-project-skeleton repository.
Run below command:
$ django-admin startproject --template=https://github.com/Mischback/django-project-skeleton/archive/development.zip [projectname]
The structure is something like this:
[projectname]/ <- project root
├── [projectname]/ <- Django root
│ ├── __init__.py
│ ├── settings/
│ │ ├── common.py
│ │ ├── development.py
│ │ ├── i18n.py
│ │ ├── __init__.py
│ │ └── production.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ └── __init__.py
├── configs/
│ ├── apache2_vhost.sample
│ └── README
├── doc/
│ ├── Makefile
│ └── source/
│ └── *snap*
├── manage.py
├── README.rst
├── run/
│ ├── media/
│ │ └── README
│ ├── README
│ └── static/
│ └── README
├── static/
│ └── README
└── templates/
├── base.html
├── core
│ └── login.html
└── README

Understanding directory structure advice

I started to create in Django sample project, first command:
django-admin.py startproject test
gives me:
- root
- test
- __init__.py
- settings.py
- urls.py
- wsgi.py
- manage.py
Now I create first app:
python manage.py startapp foo
it created for me folder root/foo
so how I should understand my root/test folder. Is this folder for global config of my project and nothing more? (similar to Symfony 2 app folder)
I am confused because Django docs tells:
The inner mysite/ directory is the actual Python package for your
project
but manage.py startapp foo create app under root, not under root/test (mysite equivalent)
[EDIT]
Two commands:
python manage.py startapp app
and:
django-admin.py startapp app
gives me app inside project root, not under root/name_of_generated_project
Django 1.4
[EDIT] 2
Sorry guys, my fault, now is everything ok.
[EDIT] 3
I want to create another project again:
django-admin.py startproject jobeet
my initial structure is similar to above.
Now I want to try create app (inside jobeet folder):
django-admin.py startapp jobs
and I end up with jobeet/jobs not jobeet/jobeet/jobs
again :/
so inside my project root I have:
- jobeet
- jobs
- manage.py
another command:
python manage.py startapp app
gives me the same result
So let's say you create a new Django project testproject:
django-admin.py startproject testproject
This creates a new project with the following minimal set of files:
testproject/
├── __init__.py
├── manage.py
├── settings.py
└── urls.py
To create a new app for your first site mysite1 go into testproject directory and run:
python manage.py startapp mysite1
which results in a new directory mysite1 for the mysite1 app.
I.e. with just these two commands you would arrive at this hierarchy:
testproject/
├── __init__.py
├── manage.py
├── mysite1
│   ├── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── settings.py
└── urls.py
Refer to the django-admin.py and/or manage.py individual commands here.
In Django there is a one-to-many relationship between a project and an app. An app is usually one individual site component (e.g. comments, ratings), whereas a project is an organisation of several apps and can power many different sites. That's why you get the sites framework. In practice, one project usually serves one website, but with Django sites app with one project you can serve as many websites as you like, for reusability's sake.
P.S. I think creating a project simply called test is not a good practice because with Django unit tests at app level unit tests will go into a file called tests.py or within a folder called tests.
UPDATE for Django 1.4
As #zeantsoi has commented below, my answer:
applies to Django 1.3 and prior. Per the docs, beginning in 1.4, base
configuration files (including settings.py, urls.py, and wsgi.py) are
abstracted into a subdirectory titled the same name as the project.
"test" is the top level of your project. I've never used symphony 2 so I can't comment on that, but it seems like you have a grasp on it. The files that live in there are basically all global config files. Inside your "test" folder you should also have one or more app folders. Inside these app folders live the apps specific models, views, urls, etc.
It seems you've got something a little wrong your foo app should live in root/test/foo not root/foo.
Now in my projects I tend to have things like a virtualenv folder live in the root dir, but you definitively shouldn't have apps at that level (it just won't work)
manage.py doesn't provide a startproject command - that's usually a django-admin command. I'd check which manage.py you're executing, and ideally, use the manage.py from the project directory you've created.