mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-10 19:57:09 +03:00
Add instruction for adding a django app (#4944)
* 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. * Update docs/developing-locally.rst Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com> * Update docs/developing-locally.rst Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com> --------- Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
This commit is contained in:
parent
a8ff250a9d
commit
bca7d02f0a
|
@ -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
|
||||
-------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user