Django the Domain Driven Design way
This is a proof of concept to model django apps on a domain driven design way. The idea is to move Django app related stuff under infrastructure folder, so ideally an app folder structure would be:
app_folder/
application/
domain/
infrastructure/
migrations/
admin.py
models.py
__init__.py
__init__.py
Installation
To install from source, download the source code, then run this:
python setup.py install
Or install with pip
pip install django-ddd
Configuration
Select your desired app folder structure and add these settings to your project.
CUSTOM_MODELS_MODULE
Where Django should look for your app models.
Default:
modelsExample:
infrastructure.models
CUSTOM_MIGRATIONS_MODULE
Where Django should look for your app migrations.
Default
migrationsExample:
infrastructure.migrations
CUSTOM_ADMIN_MODULE
Where Django should look for your app admin configuration.
Default
adminExample:
infrastructure.admin
Usage
To use custom locations
Install django-ddd to your project requirements and add settings so Django
can find your apps modules as seen on configuration.
You don't need to add django-ddd to INSTALLED_APPS
Then, on your package apps.py import django-ddd custom app config:
from django_ddd.apps_config import CleanAppConfig
class AppNameConfig(CleanAppConfig):
name = "app_name" # package folder name
Add your new application to INSTALLED_APPS
INSTALLED_APPS = [
# ...
"app_name.infrastructure.apps.AppNameConfig",
# ...
]
This should be done explicitly after this ticket.
To use start_clean_app
This command creates a new Django app with a Domain Driven Design structure.
To use it, you need to add django-ddd to your INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django_ddd",
# ...
]
Then, just call:
python manage.py start_clean_app app_name
This will create a new context with previously seen structure:
app_name/
application/
domain/
infrastructure/
migrations/
admin.py
models.py
__init__.py
__init__.py
Here all Django details are under infrastructure folder. Package level __init__.py
has route to app config:
default_app_config = "app_name.infrastructure.apps.AppNaemAppConfig"
You can move this folder to your sources
and add it to INSTALLED_APPS so Django can recognize it.
Contributing / Running project locally
Build the docker image:
docker build . -t django-ddd-dev
Run tests:
docker run -v $(pwd)/.:/usr/src/app django-ddd-dev bash -c "pipenv run python manage.py test"
Metadata
Release files for Django-ddd 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Django-ddd-0.1.11.tar.gz | 5.1 kB | Without provenance | Details for Django-ddd-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Django_ddd-0.1.11-py3-none-any.whl | Python 3 | none | any | Details for Django_ddd-0.1.11-py3-none-any.whl |
Total release size: 12.3 kB
Release files / Django-ddd-0.1.11.tar.gz
| Download URL | Django-ddd-0.1.11.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
045be877798f06f810e108b73052abbf72b8470f74187d9cebabfe99d1af0c58
|
|
BLAKE2b-256 checksum How to use checksums |
249f6ec8908c98dd1f4d9cea4e768bdf049a6d5af7338919dd0531fcf1c62800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / Django_ddd-0.1.11-py3-none-any.whl
| Download URL | Django_ddd-0.1.11-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f6d61abc533479ad0975e72f12038378bda9b1ed036b9b60e315703fe7639c5
|
|
BLAKE2b-256 checksum How to use checksums |
a275419366d8271facf6d2a44004ca5e679820d3ff6ed17bee5d8b7d2a795e11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for Django-ddd 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.