From 659d206cf6a97940d73b44199cc0e0bb68518c02 Mon Sep 17 00:00:00 2001 From: Abe Date: Sun, 24 Mar 2024 16:16:46 -0400 Subject: [PATCH] feat(docs): add instruction for adding a django app Following the the steps outlined in: https://github.com/cookiecutter/cookiecutter-django/discussions/4339#discussioncomment-5922166 this PR adds a "Creating Your First Django App" section to the docs breifly expalins the file structure and outlines the steps to add a new app. --- docs/developing-locally.rst | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index f7191d27d..ba0bbe99e 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -96,6 +96,61 @@ First things first. .. _direnv: https://direnv.net/ +Creating Your First Django App +------------------------------- + +After setting up your environment, you're ready to add your first app. This project uses the setup from "Two Scoops of Django" with a two-tier layout: + +- **Top Level Repository Root** has config files, documentation, `manage.py`, and more. +- **Second Level Django Project Root** is where your Django apps live. +- **Second Level Configuration Root** holds settings and URL configurations. + +The project layout looks something like this: :: + + / + ├── config/ + │ ├── settings/ + │ │ ├── __init__.py + │ │ ├── base.py + │ │ ├── local.py + │ │ └── production.py + │ ├── urls.py + │ └── wsgi.py + ├── / + │ ├── / + │ │ ├── migrations/ + │ │ ├── admin.py + │ │ ├── apps.py + │ │ ├── models.py + │ │ ├── tests.py + │ │ └── views.py + │ ├── __init__.py + │ └── ... + ├── requirements/ + │ ├── base.txt + │ ├── local.txt + │ └── production.txt + ├── manage.py + ├── README.md + └── ... + + +Following this structured approach, here's how to add a new app: + +#. **Create the app** using Django's ``startapp`` command, replacing ```` with your desired app name: :: + + $ python manage.py startapp + +#. **Move the app** to the Django Project Root, maintaining the project's two-tier structure: :: + + $ mv / + +#. **Edit the app's apps.py** change ``name = ''`` to ``name = '.'``: + +#. **Register the new app** by adding it to the ``LOCAL_APPS`` list in ``config/settings/base.py``, integrating it as an official component of your project: + + + Setup Email Backend -------------------