Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django directory structure?

Tags:

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?

like image 877
Cory Avatar asked Jun 26 '12 22:06

Cory


People also ask

How do I organize a Django project?

The way I like to organize my Django Project is – Keeps all Django apps in apps folder, static files (scripts, js, CSS) in the static folder, HTML files in templates folder and images and media content in the media folder.

What are the files created in Django project?

apps.py is a configuration file common to all Django apps. models.py is the module containing the models for your app basically ORM modelling. tests.py contains test procedures which run when testing your app. views.py is the module containing the views for your app or where we write our business logic.

Can a Django project have multiple apps?

Any Django project consists of multiple applications.

What is difference between project and app in Django?

The difference between a project and app is, a project is a collection of configuration files and apps whereas the app is a web application which is written to perform business logic.


1 Answers

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 
like image 109
9 revs, 2 users 86% Avatar answered Oct 09 '22 18:10

9 revs, 2 users 86%