Zach Valenta
Zach Valenta

Reputation: 1889

Is there a naming convention for Django project/configuration directory?

I'm referring to the directory holding settings.py and wsgi.py (Two Scoops of Django refers to this as the 'configuration root', for what it's worth)

I've seen people name this directory after the actual project name (the official Django tutorial does this) but that leads to a redundant/confusing directory structure like the following:

mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        wsgi.py
    app1/
    app2/

seems like it'd be more clear to have something like the following:

mysite/
    manage.py
    conf/
        __init__.py
        settings.py
        urls.py
        wsgi.py
    app1/
    app2/

I see that there is already a question about Django app naming conventions but couldn't find anything regarding the project/conf directory.

To be clear, I'm asking about what to name the directory, not formatting conventions (underscores, lowercase vs. upper, etc.).

Upvotes: 7

Views: 3661

Answers (2)

Taylor Vance
Taylor Vance

Reputation: 1001

There is some good discussion on this topic here. Some generic options are project, config, core, base. I'm partial to "project" (/mysite/project/settings.py etc). To set up a new project like this, cd into your empty base directory and run django-admin startproject project ..

I've never been a fan of the default convention. It seems redundant and often conflicts with what I want to name my "main app". For example, I want to make a time tracking site, so I call my project "timers" (/timers/timers/settings.py etc). But now I can't start an app called timers, which is the best name for the app where I keep the timer model etc. If I name my project "project" then I can still have an app called "timers".

timers/
  manage.py
  project/
    settings.py
  timers/
    models.py

Upvotes: 8

Sam
Sam

Reputation: 845

Generally you should use the pattern which you use for any package or module. 1. small letter 2. Underscore (_) if needed. If you don't want to use redundant name you just add dot(.) after a space after roject creation command.
django-admin.py startproject myproject .

Upvotes: 0

Related Questions