23

I would like to implement a simple queueing service specific to a project. Where should the code go into in the Django directory structure?

Currently the structure is:

sound/ __init__.py models.py tests.py views.py static 

[edit] I am asking where to place the queue service code I created within the direcotry structure above. Should I create a new directory?

2
  • possible duplicate of stackoverflow.com/questions/2282034/… Commented Jun 26, 2012 at 22:43
  • Are you asking where to place this sound app folder? Commented Jun 26, 2012 at 23:46

2 Answers 2

63

Common structures

In Django 1.4+

project_root/ project_name/ media/ static/ some_app/css/app.css # overriding an app css file from project level css/ project.css static_root/ # in production using the collectstatic command templates/some_app/foo.html # overriding some_app at project level /admin/some_app/some_model/change_list.html # overriding admin changelist for some_app.models.some_model settings/ __init__.py base.py # settings common to all instances of the project dev.py staging.py test.py prod.py urls.py some_app/ static/ css/ app.css templates/some_app/foo.html urls.py views.py models.py manage.py 

In Django 1.3 and prior

project_root/ some_app/ templates/some_app/foo.html static/ css/ app.css urls.py views.py models.py media/ static/ some_app/ css/ app.css # overriding an app css file from project level css/ project.css static_root/ (in production) templates/some_app/foo.html # overriding some_app at project level /admin/some_app/some_model/change_list.html # overriding admin changelist for some_app.models.some_model settings/ __init__.py base.py # settings common to all instances of the project dev.py staging.py test.py prod.py urls.py manage.py 

Alternative approach

project_root/ .gitignore README.md docs/ venv/ src/ main/ media/ static/ some_app/css/app.css # overriding an app css file from project level css/ project.css static_root/ # in production using the collectstatic command templates/some_app/foo.html # overriding some_app at project level /admin/some_app/some_model/change_list.html # overriding admin changelist for some_app.models.some_model settings/ __init__.py base.py dev.py staging.py test.py prod.py urls.py some_app/ static/ css/ app.css templates/some_app/foo.html urls.py views.py models.py manage.py wsgi.py 
Sign up to request clarification or add additional context in comments.

4 Comments

Where would you add templates?
@starsinmypockets per app you can add your default templates, probably without too much styling. At project level your override these, I have updated the example with templates.
why override templates at project level?
interesting because in the Django tutorial02, in order to override /admin/ templates, the custom template folder must be above the app, and above the project folder -- at the top-most level with manage.py. It seems counter-intuitive that it's not within the app (as it is a change we're applying specific to the app, no?)
1

If you need to use the database, you should add the data models to models.py. For your program I recommend writing it in new python files (e.g. queuing.py) that you would import when and where you want to use it. You could create another django app just for this as well.

1 Comment

You could create another django app just for this as well. That's not a good recommendation. The service code should be separated from MVC. In general, it's just not another app.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.