Project Structure
Directory Structure
Organize Django projects using the standard layout for maintainability and scalability. Each Django project should contain one or more apps, each with a clear purpose.
Example:
myproject/
manage.py
myproject/
__init__.py
settings.py
urls.py
wsgi.py
asgi.py
app1/
__init__.py
admin.py
apps.py
migrations/
models.py
tests.py
views.py
forms.py
templates/app1/
static/app1/
app2/
...
templates/
static/
requirements.txt
.env
Apps
- Each app should represent a distinct feature or domain (e.g., users, invoices, blog).
- Avoid monolithic apps; split functionality into logical apps.
- Use descriptive app names in lowercase.
Best Practices
- Place reusable code in separate apps or modules.
- Store templates and static files in app-specific folders for modularity.
- Use environment variables for secrets and configuration.
- Keep the root directory clean; avoid placing custom code outside apps.
- Document custom directories and their purpose for new team members.