Skip to content

Commit

Permalink
Add instruction for adding a django app (cookiecutter#4944)
Browse files Browse the repository at this point in the history
* feat(docs): add instruction for adding a django app

Following the the steps outlined in:
cookiecutter#4339 (comment)
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.

* Update docs/developing-locally.rst

Co-authored-by: Bruno Alla <[email protected]>

* Update docs/developing-locally.rst

Co-authored-by: Bruno Alla <[email protected]>

---------

Co-authored-by: Bruno Alla <[email protected]>
  • Loading branch information
abe-101 and browniebroke authored Mar 29, 2024
1 parent a8ff250 commit bca7d02
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions docs/developing-locally.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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: ::

<repository_root>/
├── config/
│ ├── settings/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── local.py
│ │ └── production.py
│ ├── urls.py
│ └── wsgi.py
├── <django_project_root>/
│ ├── <name_of_the_app>/
│ │ ├── 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 ``<name-of-the-app>`` with your desired app name: ::

$ python manage.py startapp <name-of-the-app>

#. **Move the app** to the Django Project Root, maintaining the project's two-tier structure: ::

$ mv <name-of-the-app> <django_project_root>/

#. **Edit the app's apps.py** change ``name = '<name-of-the-app>'`` to ``name = '<django_project_root>.<name-of-the-app>'``.

#. **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
-------------------

Expand Down

0 comments on commit bca7d02

Please sign in to comment.