django-cfg 1.2.10__py3-none-any.whl → 1.2.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_cfg/__init__.py +1 -1
- django_cfg/apps/accounts/migrations/0007_twilioresponse.py +126 -0
- django_cfg/cli/README.md +2 -2
- django_cfg/cli/commands/create_project.py +1 -1
- django_cfg/cli/commands/info.py +1 -1
- django_cfg/modules/django_llm/llm/client.py +2 -2
- django_cfg-1.2.11.dist-info/METADATA +554 -0
- {django_cfg-1.2.10.dist-info → django_cfg-1.2.11.dist-info}/RECORD +11 -10
- django_cfg-1.2.10.dist-info/METADATA +0 -1277
- {django_cfg-1.2.10.dist-info → django_cfg-1.2.11.dist-info}/WHEEL +0 -0
- {django_cfg-1.2.10.dist-info → django_cfg-1.2.11.dist-info}/entry_points.txt +0 -0
- {django_cfg-1.2.10.dist-info → django_cfg-1.2.11.dist-info}/licenses/LICENSE +0 -0
@@ -1,1277 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: django-cfg
|
3
|
-
Version: 1.2.10
|
4
|
-
Summary: 🚀 Next-gen Django configuration: type-safety, AI features, blazing-fast setup, and automated best practices — all in one.
|
5
|
-
Project-URL: Homepage, https://django-cfg.com
|
6
|
-
Project-URL: Documentation, https://django-cfg.com
|
7
|
-
Project-URL: Repository, https://django-cfg.com
|
8
|
-
Project-URL: Issues, https://django-cfg.com
|
9
|
-
Project-URL: Changelog, https://django-cfg.com
|
10
|
-
Author-email: ReformsAI Team <dev@reforms.ai>
|
11
|
-
Maintainer-email: ReformsAI Team <dev@reforms.ai>
|
12
|
-
License: MIT
|
13
|
-
License-File: LICENSE
|
14
|
-
Keywords: configuration,developer-experience,django,pydantic,settings,type-safety
|
15
|
-
Classifier: Development Status :: 4 - Beta
|
16
|
-
Classifier: Framework :: Django
|
17
|
-
Classifier: Framework :: Django :: 5.2
|
18
|
-
Classifier: Intended Audience :: Developers
|
19
|
-
Classifier: License :: OSI Approved :: MIT License
|
20
|
-
Classifier: Operating System :: OS Independent
|
21
|
-
Classifier: Programming Language :: Python
|
22
|
-
Classifier: Programming Language :: Python :: 3
|
23
|
-
Classifier: Programming Language :: Python :: 3.10
|
24
|
-
Classifier: Programming Language :: Python :: 3.11
|
25
|
-
Classifier: Programming Language :: Python :: 3.12
|
26
|
-
Classifier: Programming Language :: Python :: 3.13
|
27
|
-
Classifier: Topic :: Internet :: WWW/HTTP
|
28
|
-
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
29
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
30
|
-
Classifier: Topic :: System :: Systems Administration
|
31
|
-
Classifier: Typing :: Typed
|
32
|
-
Requires-Python: <4.0,>=3.12
|
33
|
-
Requires-Dist: beautifulsoup4<5.0,>=4.13.0
|
34
|
-
Requires-Dist: cachetools<7.0,>=5.3.0
|
35
|
-
Requires-Dist: click<9.0,>=8.2.0
|
36
|
-
Requires-Dist: colorlog<7.0,>=6.9.0
|
37
|
-
Requires-Dist: coolname<3.0,>=2.2.0
|
38
|
-
Requires-Dist: currencyconverter<1.0,>=0.18.0
|
39
|
-
Requires-Dist: dj-database-url<4.0,>=3.0.0
|
40
|
-
Requires-Dist: django-admin-rangefilter<1.0,>=0.13.0
|
41
|
-
Requires-Dist: django-constance<5.0,>=4.3.0
|
42
|
-
Requires-Dist: django-cors-headers<5.0,>=4.7.0
|
43
|
-
Requires-Dist: django-dramatiq<1.0,>=0.14.0
|
44
|
-
Requires-Dist: django-extensions<5.0,>=4.1.0
|
45
|
-
Requires-Dist: django-filter<26.0,>=25.0
|
46
|
-
Requires-Dist: django-import-export<5.0,>=4.3.0
|
47
|
-
Requires-Dist: django-json-widget<3.0,>=2.0.0
|
48
|
-
Requires-Dist: django-ratelimit<5.0.0,>=4.1.0
|
49
|
-
Requires-Dist: django-redis<7.0,>=6.0.0
|
50
|
-
Requires-Dist: django-revolution<2.0,>=1.0.43
|
51
|
-
Requires-Dist: django-unfold<1.0,>=0.64.0
|
52
|
-
Requires-Dist: djangorestframework-simplejwt<6.0,>=5.5.0
|
53
|
-
Requires-Dist: djangorestframework-simplejwt[token-blacklist]<6.0,>=5.5.0
|
54
|
-
Requires-Dist: djangorestframework<4.0,>=3.16.0
|
55
|
-
Requires-Dist: dramatiq[redis]<2.0,>=1.18.0
|
56
|
-
Requires-Dist: drf-nested-routers<1.0,>=0.94.0
|
57
|
-
Requires-Dist: drf-spectacular-sidecar<2026.0,>=2025.8.0
|
58
|
-
Requires-Dist: drf-spectacular<1.0,>=0.28.0
|
59
|
-
Requires-Dist: hiredis<4.0,>=2.0.0
|
60
|
-
Requires-Dist: loguru<1.0,>=0.7.0
|
61
|
-
Requires-Dist: lxml<7.0,>=6.0.0
|
62
|
-
Requires-Dist: ngrok>=1.5.1; python_version >= '3.12'
|
63
|
-
Requires-Dist: openai<2.0,>=1.107.0
|
64
|
-
Requires-Dist: pgvector<1.0,>=0.4.0
|
65
|
-
Requires-Dist: psycopg[binary,pool]<4.0,>=3.2.0
|
66
|
-
Requires-Dist: pydantic-ai<2.0,>=1.0.10
|
67
|
-
Requires-Dist: pydantic-yaml<2.0,>=1.6.0
|
68
|
-
Requires-Dist: pydantic<3.0,>=2.11.0
|
69
|
-
Requires-Dist: pydantic[email]<3.0,>=2.11.0
|
70
|
-
Requires-Dist: pytelegrambotapi<5.0,>=4.28.0
|
71
|
-
Requires-Dist: python-json-logger<4.0,>=3.3.0
|
72
|
-
Requires-Dist: pyyaml<7.0,>=6.0
|
73
|
-
Requires-Dist: questionary<3.0,>=2.1.0
|
74
|
-
Requires-Dist: redis<7.0,>=6.4.0
|
75
|
-
Requires-Dist: requests<3.0,>=2.32.0
|
76
|
-
Requires-Dist: rich<15.0,>=14.0.0
|
77
|
-
Requires-Dist: sendgrid<7.0,>=6.12.0
|
78
|
-
Requires-Dist: tiktoken<1.0,>=0.11.0
|
79
|
-
Requires-Dist: toml<0.11.0,>=0.10.2
|
80
|
-
Requires-Dist: twilio<10.0,>=9.8.0
|
81
|
-
Requires-Dist: whitenoise<7.0,>=6.8.0
|
82
|
-
Provides-Extra: dev
|
83
|
-
Requires-Dist: black<26.0,>=25.9; extra == 'dev'
|
84
|
-
Requires-Dist: build<2.0,>=1.3; extra == 'dev'
|
85
|
-
Requires-Dist: django<6.0,>=5.2; extra == 'dev'
|
86
|
-
Requires-Dist: factory-boy<4.0,>=3.3; extra == 'dev'
|
87
|
-
Requires-Dist: flake8<8.0,>=6.0.0; extra == 'dev'
|
88
|
-
Requires-Dist: isort<7.0,>=6.0; extra == 'dev'
|
89
|
-
Requires-Dist: mkdocs-material<10.0,>=9.6; extra == 'dev'
|
90
|
-
Requires-Dist: mkdocs<2.0,>=1.6; extra == 'dev'
|
91
|
-
Requires-Dist: mkdocstrings[python]<1.0,>=0.30; extra == 'dev'
|
92
|
-
Requires-Dist: mypy<2.0,>=1.18; extra == 'dev'
|
93
|
-
Requires-Dist: pre-commit<5.0,>=4.3; extra == 'dev'
|
94
|
-
Requires-Dist: pytest-cov<8.0,>=7.0; extra == 'dev'
|
95
|
-
Requires-Dist: pytest-django<5.0,>=4.11; extra == 'dev'
|
96
|
-
Requires-Dist: pytest-mock<4.0,>=3.15; extra == 'dev'
|
97
|
-
Requires-Dist: pytest<9.0,>=8.4; extra == 'dev'
|
98
|
-
Requires-Dist: questionary<3.0,>=2.1.0; extra == 'dev'
|
99
|
-
Requires-Dist: redis<7.0,>=6.4.0; extra == 'dev'
|
100
|
-
Requires-Dist: rich<15.0,>=13.0.0; extra == 'dev'
|
101
|
-
Requires-Dist: tomlkit<1.0,>=0.13.3; extra == 'dev'
|
102
|
-
Requires-Dist: twine<7.0,>=6.2; extra == 'dev'
|
103
|
-
Provides-Extra: django52
|
104
|
-
Requires-Dist: django<6.0,>=5.2; extra == 'django52'
|
105
|
-
Provides-Extra: docs
|
106
|
-
Requires-Dist: mkdocs-material<10.0,>=9.6; extra == 'docs'
|
107
|
-
Requires-Dist: mkdocs<2.0,>=1.6; extra == 'docs'
|
108
|
-
Requires-Dist: mkdocstrings[python]<1.0,>=0.30; extra == 'docs'
|
109
|
-
Requires-Dist: pymdown-extensions<11.0,>=10.16; extra == 'docs'
|
110
|
-
Provides-Extra: full
|
111
|
-
Requires-Dist: django<6.0,>=5.2; extra == 'full'
|
112
|
-
Requires-Dist: redis<7.0,>=6.4.0; extra == 'full'
|
113
|
-
Provides-Extra: local
|
114
|
-
Provides-Extra: tasks
|
115
|
-
Requires-Dist: redis<7.0,>=6.4.0; extra == 'tasks'
|
116
|
-
Provides-Extra: test
|
117
|
-
Requires-Dist: django<6.0,>=5.2; extra == 'test'
|
118
|
-
Requires-Dist: factory-boy<4.0,>=3.3; extra == 'test'
|
119
|
-
Requires-Dist: pytest-cov<8.0,>=7.0; extra == 'test'
|
120
|
-
Requires-Dist: pytest-django<5.0,>=4.11; extra == 'test'
|
121
|
-
Requires-Dist: pytest-mock<4.0,>=3.15; extra == 'test'
|
122
|
-
Requires-Dist: pytest-xdist<4.0,>=3.8; extra == 'test'
|
123
|
-
Requires-Dist: pytest<9.0,>=8.4; extra == 'test'
|
124
|
-
Description-Content-Type: text/markdown
|
125
|
-
|
126
|
-
# 🚀 Django-CFG: The Configuration Revolution
|
127
|
-
|
128
|
-
[](https://pypi.org/project/django-cfg/)
|
129
|
-
[](https://pypi.org/project/django-cfg/)
|
130
|
-
[](https://github.com/markolofsen/django-cfg/blob/main/LICENSE)
|
131
|
-
[](https://pypi.org/project/django-cfg/)
|
132
|
-
|
133
|
-
> **Create a production-ready Django project in 30 seconds, not 30 hours.**
|
134
|
-
|
135
|
-
Skip the setup hell. Django-CFG creates a complete, modern Django project with everything you need: beautiful admin, API docs, user management, newsletter system, support tickets, and more.
|
136
|
-
|
137
|
-
## 🎯 Create Your Project Right Now
|
138
|
-
|
139
|
-
### Requirements
|
140
|
-
- **Python 3.12+** - [Download here](https://www.python.org/downloads/) or use `brew install python@3.12`
|
141
|
-
|
142
|
-
### Quick Start
|
143
|
-
```bash
|
144
|
-
# Create virtual environment with Python 3.12
|
145
|
-
python3.12 -m venv .venv
|
146
|
-
|
147
|
-
# Activate virtual environment
|
148
|
-
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
149
|
-
|
150
|
-
# Install Django-CFG
|
151
|
-
pip install django-cfg
|
152
|
-
|
153
|
-
# Create a complete project instantly
|
154
|
-
django-cfg create-project "My Awesome Project"
|
155
|
-
|
156
|
-
# Enter the project and run
|
157
|
-
cd my-awesome-project
|
158
|
-
python manage.py runserver
|
159
|
-
```
|
160
|
-
|
161
|
-
**🎉 That's it!** Your app is now running:
|
162
|
-
- **🚀 Main app:** http://127.0.0.1:8000/
|
163
|
-
- **🎯 Admin panel:** http://127.0.0.1:8000/admin/
|
164
|
-
- **📚 API docs:** http://127.0.0.1:8000/api/docs/
|
165
|
-
|
166
|
-
**That's it!** 🎉 You now have a **production-ready Django project** with:
|
167
|
-
- ✅ **Beautiful admin interface** with Unfold + Tailwind CSS
|
168
|
-
- ✅ **Complete API documentation** with Swagger/ReDoc
|
169
|
-
- ✅ **Multi-channel user management** with email & SMS OTP authentication
|
170
|
-
- ✅ **SMS & WhatsApp integration** with Twilio out of the box
|
171
|
-
- ✅ **Support ticket system** with chat interface
|
172
|
-
- ✅ **Newsletter campaigns** with email tracking
|
173
|
-
- ✅ **Lead management** system with CRM integration
|
174
|
-
- ✅ **Multi-database routing** and connection pooling
|
175
|
-
- ✅ **Background task processing** with production-ready Dramatiq integration
|
176
|
-
- ✅ **Webhook testing** with built-in ngrok integration
|
177
|
-
- ✅ **Type-safe configuration** with full IDE support
|
178
|
-
|
179
|
-
|
180
|
-
### 📦 Alternative Installation Methods
|
181
|
-
|
182
|
-
#### Using Poetry (recommended for development)
|
183
|
-
```bash
|
184
|
-
# Create new project directory
|
185
|
-
mkdir my-project && cd my-project
|
186
|
-
|
187
|
-
# Initialize Poetry project
|
188
|
-
poetry init --no-interaction
|
189
|
-
|
190
|
-
# Add Django-CFG
|
191
|
-
poetry add django-cfg
|
192
|
-
|
193
|
-
# Create project
|
194
|
-
poetry run django-cfg create-project "My Project"
|
195
|
-
```
|
196
|
-
|
197
|
-
#### Using pipenv
|
198
|
-
```bash
|
199
|
-
# Create virtual environment and install
|
200
|
-
pipenv install django-cfg
|
201
|
-
|
202
|
-
# Create project
|
203
|
-
pipenv run django-cfg create-project "My Project"
|
204
|
-
```
|
205
|
-
|
206
|
-
#### Using conda
|
207
|
-
```bash
|
208
|
-
# Create conda environment with Python 3.12+
|
209
|
-
conda create -n myproject python=3.12
|
210
|
-
conda activate myproject
|
211
|
-
|
212
|
-
# Install Django-CFG
|
213
|
-
conda install -c conda-forge django-cfg
|
214
|
-
# OR: pip install django-cfg
|
215
|
-
|
216
|
-
# Create project
|
217
|
-
django-cfg create-project "My Project"
|
218
|
-
```
|
219
|
-
|
220
|
-
### ⚠️ Troubleshooting
|
221
|
-
|
222
|
-
#### Python Version Error
|
223
|
-
If you see an error like "django-cfg requires Python 3.12 or higher", upgrade your Python:
|
224
|
-
|
225
|
-
```bash
|
226
|
-
# macOS (using Homebrew)
|
227
|
-
brew install python@3.12
|
228
|
-
|
229
|
-
# Ubuntu/Debian
|
230
|
-
sudo apt update
|
231
|
-
sudo apt install python3.12
|
232
|
-
|
233
|
-
# Using pyenv (recommended)
|
234
|
-
pyenv install 3.12.0
|
235
|
-
pyenv global 3.12.0
|
236
|
-
|
237
|
-
# Windows
|
238
|
-
# Download from https://www.python.org/downloads/
|
239
|
-
```
|
240
|
-
|
241
|
-
#### Virtual Environment Issues
|
242
|
-
```bash
|
243
|
-
# If python3.12 command not found, check available versions:
|
244
|
-
ls /usr/bin/python*
|
245
|
-
ls /usr/local/bin/python*
|
246
|
-
|
247
|
-
# Try alternative commands:
|
248
|
-
python3.12 -m venv .venv # Preferred
|
249
|
-
/usr/local/bin/python3.12 -m venv .venv # Full path
|
250
|
-
|
251
|
-
# Or use virtualenv:
|
252
|
-
pip install virtualenv
|
253
|
-
virtualenv -p python3.12 .venv
|
254
|
-
```
|
255
|
-
|
256
|
-
---
|
257
|
-
|
258
|
-
## 🔥 Why Django-CFG Changes Everything
|
259
|
-
|
260
|
-
### The Problem with Traditional Django
|
261
|
-
- **500+ line settings files** that nobody wants to touch
|
262
|
-
- **Zero type safety** - typos break production
|
263
|
-
- **Manual everything** - databases, caching, admin, APIs
|
264
|
-
- **Environment hell** - different configs everywhere
|
265
|
-
- **Ugly admin interface** stuck in 2010
|
266
|
-
- **No API documentation** without hours of setup
|
267
|
-
|
268
|
-
### The Django-CFG Solution
|
269
|
-
- **Type-safe configuration** with Pydantic validation
|
270
|
-
- **100% type-safe** with full IDE support
|
271
|
-
- **Smart automation** that knows what you need
|
272
|
-
- **Environment detection** that just works
|
273
|
-
- **Beautiful modern admin** with Tailwind CSS
|
274
|
-
- **Auto-generated API docs** and client libraries
|
275
|
-
|
276
|
-
---
|
277
|
-
|
278
|
-
## 🎨 Customize Your Project
|
279
|
-
|
280
|
-
After creating your project with `django-cfg create-project`, you can customize it further:
|
281
|
-
|
282
|
-
### 1. **Environment Configuration**
|
283
|
-
```yaml
|
284
|
-
# config/config.dev.yaml
|
285
|
-
secret_key: "your-development-secret-key"
|
286
|
-
debug: true
|
287
|
-
database:
|
288
|
-
url: "postgresql://user:pass@localhost:5432/mydb"
|
289
|
-
redis_url: "redis://localhost:6379/0"
|
290
|
-
```
|
291
|
-
|
292
|
-
### 2. **Type-Safe Configuration**
|
293
|
-
```python
|
294
|
-
# config.py - Automatically generated and customizable
|
295
|
-
from django_cfg import DjangoConfig
|
296
|
-
|
297
|
-
class MyConfig(DjangoConfig):
|
298
|
-
project_name: str = "MyAwesomeApp" # Auto-set from CLI
|
299
|
-
secret_key: str = env.secret_key
|
300
|
-
debug: bool = env.debug
|
301
|
-
project_apps: list[str] = ["accounts", "blog", "shop"]
|
302
|
-
|
303
|
-
# Enable/disable built-in modules
|
304
|
-
enable_support: bool = True # Support ticket system
|
305
|
-
enable_accounts: bool = True # Advanced user management
|
306
|
-
enable_newsletter: bool = True # Email marketing
|
307
|
-
enable_leads: bool = True # Lead capture & CRM
|
308
|
-
|
309
|
-
config = MyConfig()
|
310
|
-
```
|
311
|
-
|
312
|
-
### 3. **Advanced Features**
|
313
|
-
```python
|
314
|
-
from django_cfg import DatabaseConfig, UnfoldConfig, RevolutionConfig
|
315
|
-
|
316
|
-
class ProductionConfig(DjangoConfig):
|
317
|
-
# Multi-database setup
|
318
|
-
databases: dict[str, DatabaseConfig] = {
|
319
|
-
"default": DatabaseConfig(engine="postgresql", ...),
|
320
|
-
"analytics": DatabaseConfig(routing_apps=["analytics"]),
|
321
|
-
}
|
322
|
-
|
323
|
-
# Beautiful admin customization
|
324
|
-
unfold: UnfoldConfig = UnfoldConfig(
|
325
|
-
site_title="My Admin",
|
326
|
-
theme="auto", # auto/light/dark
|
327
|
-
dashboard_callback="myapp.dashboard.main_callback",
|
328
|
-
)
|
329
|
-
|
330
|
-
# Multi-zone API architecture
|
331
|
-
revolution: RevolutionConfig = RevolutionConfig(
|
332
|
-
zones={
|
333
|
-
"public": ZoneConfig(apps=["blog"], public=True),
|
334
|
-
"admin": ZoneConfig(apps=["management"], auth_required=True),
|
335
|
-
}
|
336
|
-
)
|
337
|
-
```
|
338
|
-
|
339
|
-
### 4. **CLI Commands & Project Info**
|
340
|
-
```bash
|
341
|
-
# Get information about available templates and CLI
|
342
|
-
django-cfg info
|
343
|
-
|
344
|
-
# Show help for all commands
|
345
|
-
django-cfg --help
|
346
|
-
|
347
|
-
# Create project with specific directory name
|
348
|
-
django-cfg create-project "My Project" --directory my-custom-dir
|
349
|
-
```
|
350
|
-
|
351
|
-
---
|
352
|
-
|
353
|
-
## 🏆 Feature Comparison
|
354
|
-
|
355
|
-
| Feature | Traditional Django | Django-CFG |
|
356
|
-
|---------|-------------------|-------------|
|
357
|
-
| **📝 Configuration** | 500+ lines of settings hell | **Type-safe & organized** |
|
358
|
-
| **🔒 Type Safety** | Pray and hope | **100% validated** |
|
359
|
-
| **🎨 Admin Interface** | Ugly 2010 design | **Modern Unfold + Tailwind** |
|
360
|
-
| **📊 Dashboard** | Basic admin index | **Real-time metrics & widgets** |
|
361
|
-
| **🗄️ Multi-Database** | Manual routing nightmare | **Smart auto-routing** |
|
362
|
-
| **⚡ Commands** | Terminal only | **Beautiful web interface** |
|
363
|
-
| **📚 API Docs** | Hours of manual setup | **Auto-generated OpenAPI** |
|
364
|
-
| **📦 Client Generation** | Write clients manually | **Auto TS/Python clients** |
|
365
|
-
| **🎫 Support System** | Build from scratch | **Built-in tickets & chat** |
|
366
|
-
| **👤 User Management** | Basic User model | **OTP auth & profiles** |
|
367
|
-
| **📧 Notifications** | Manual SMTP/webhooks | **Email & Telegram & LLM** |
|
368
|
-
| **🚀 Deployment** | Cross fingers | **Production-ready defaults** |
|
369
|
-
| **🌐 Webhook Testing** | Manual ngrok setup | **Built-in ngrok integration** |
|
370
|
-
| **🔄 Background Tasks** | Manual Celery/RQ setup | **Built-in Dramatiq integration** |
|
371
|
-
| **💡 IDE Support** | Basic syntax highlighting | **Full IntelliSense paradise** |
|
372
|
-
| **🐛 Config Errors** | Runtime surprises | **Compile-time validation** |
|
373
|
-
| **😊 Developer Joy** | Constant frustration | **Pure coding bliss** |
|
374
|
-
|
375
|
-
---
|
376
|
-
|
377
|
-
## 🎯 Core Features
|
378
|
-
|
379
|
-
### 🔒 **Type-Safe Configuration**
|
380
|
-
Full Pydantic validation with IDE autocomplete and compile-time error checking.
|
381
|
-
|
382
|
-
### 🎨 **Beautiful Admin Interface**
|
383
|
-
Modern Django Unfold admin with Tailwind CSS, dark mode, and custom dashboards.
|
384
|
-
|
385
|
-
### 📊 **Real-Time Dashboard**
|
386
|
-
Live metrics, system health, and custom widgets that update automatically.
|
387
|
-
|
388
|
-
### 🗄️ **Smart Multi-Database**
|
389
|
-
Automatic database routing based on app labels with connection pooling.
|
390
|
-
|
391
|
-
### ⚡ **Web Command Interface**
|
392
|
-
Run Django management commands from a beautiful web interface with real-time logs.
|
393
|
-
|
394
|
-
### 📚 **Auto API Documentation**
|
395
|
-
OpenAPI/Swagger docs generated automatically with zone-based architecture.
|
396
|
-
|
397
|
-
### 📦 **Client Generation**
|
398
|
-
TypeScript and Python API clients generated per zone automatically.
|
399
|
-
|
400
|
-
### 🎫 **Built-in Support System**
|
401
|
-
Complete ticket management with modern chat interface, email notifications, and admin integration.
|
402
|
-
|
403
|
-
### 👤 **Advanced User Management**
|
404
|
-
Built-in accounts system with OTP authentication, user profiles, activity tracking, and registration sources.
|
405
|
-
|
406
|
-
### 📧 **Built-in Modules**
|
407
|
-
Email, Telegram, SMS (Twilio), LLM integration, Support ticket system, Newsletter campaigns, Lead management, and advanced User management ready out of the box.
|
408
|
-
|
409
|
-
### 🌍 **Environment Detection**
|
410
|
-
Automatic dev/staging/production detection with appropriate defaults.
|
411
|
-
|
412
|
-
### 🌐 **Built-in Ngrok Integration**
|
413
|
-
Instant webhook testing with zero-config ngrok tunnels for development.
|
414
|
-
|
415
|
-
### 🔄 **Background Task Processing** %%PRIORITY:HIGH%%
|
416
|
-
|
417
|
-
Django-CFG includes a complete Dramatiq integration for reliable background job processing with automatic Redis configuration, worker management, and task monitoring.
|
418
|
-
|
419
|
-
#### Features
|
420
|
-
- **🚀 Zero Configuration** - Automatic Redis broker setup and queue management
|
421
|
-
- **⚡ Smart Worker Management** - Built-in `rundramatiq` command with Django settings integration
|
422
|
-
- **🔧 Type-Safe Task Definition** - Full IDE support for task creation and scheduling
|
423
|
-
- **📊 Task Monitoring** - Built-in commands for queue status and task management
|
424
|
-
- **🐳 Docker Ready** - Pre-configured Docker containers for production deployment
|
425
|
-
- **🛡️ Production Tested** - Battle-tested configuration used in production environments
|
426
|
-
|
427
|
-
#### Quick Setup
|
428
|
-
```python
|
429
|
-
from django_cfg import DjangoConfig
|
430
|
-
|
431
|
-
class MyConfig(DjangoConfig):
|
432
|
-
project_name: str = "My App"
|
433
|
-
|
434
|
-
# Dramatiq configuration (automatic)
|
435
|
-
redis_url: str = "redis://localhost:6379/2" # Separate DB for tasks
|
436
|
-
|
437
|
-
# Optional: Custom task settings
|
438
|
-
dramatiq: DramatiqConfig = DramatiqConfig(
|
439
|
-
processes=2, # Worker processes
|
440
|
-
threads=4, # Threads per process
|
441
|
-
redis_db=2, # Redis database for tasks
|
442
|
-
queues=["default", "high", "low"] # Available queues
|
443
|
-
)
|
444
|
-
|
445
|
-
config = MyConfig()
|
446
|
-
```
|
447
|
-
|
448
|
-
#### Task Definition
|
449
|
-
```python
|
450
|
-
import dramatiq
|
451
|
-
from django_cfg.modules.django_tasks import get_broker
|
452
|
-
|
453
|
-
# Tasks are automatically discovered from your apps
|
454
|
-
@dramatiq.actor(queue_name="high", max_retries=3)
|
455
|
-
def process_document(document_id: str) -> dict:
|
456
|
-
"""Process document asynchronously with full Django context."""
|
457
|
-
from myapp.models import Document
|
458
|
-
|
459
|
-
document = Document.objects.get(id=document_id)
|
460
|
-
# Your processing logic here
|
461
|
-
document.status = "processed"
|
462
|
-
document.save()
|
463
|
-
|
464
|
-
return {"status": "completed", "document_id": document_id}
|
465
|
-
|
466
|
-
# Queue the task
|
467
|
-
process_document.send(document_id="123")
|
468
|
-
```
|
469
|
-
|
470
|
-
#### Management Commands
|
471
|
-
```bash
|
472
|
-
# Start Dramatiq workers with Django settings
|
473
|
-
python manage.py rundramatiq --processes 4 --threads 8
|
474
|
-
|
475
|
-
# Monitor task queues and status
|
476
|
-
python manage.py task_status --queue high
|
477
|
-
|
478
|
-
# Clear specific queues
|
479
|
-
python manage.py task_clear --queue default
|
480
|
-
|
481
|
-
# Test task processing pipeline
|
482
|
-
python manage.py test_tasks
|
483
|
-
```
|
484
|
-
|
485
|
-
#### Docker Integration
|
486
|
-
```yaml
|
487
|
-
# docker-compose.yml (automatically generated)
|
488
|
-
services:
|
489
|
-
app-dramatiq:
|
490
|
-
build: .
|
491
|
-
command: ["python", "manage.py", "rundramatiq"]
|
492
|
-
environment:
|
493
|
-
- DRAMATIQ_PROCESSES=2
|
494
|
-
- DRAMATIQ_THREADS=4
|
495
|
-
- DRAMATIQ_QUEUES=default,high,low
|
496
|
-
depends_on:
|
497
|
-
- redis
|
498
|
-
- postgres
|
499
|
-
```
|
500
|
-
|
501
|
-
#### Production Features
|
502
|
-
- **🔄 Automatic Restart** - Workers restart on code changes in development
|
503
|
-
- **📈 Scaling** - Easy horizontal scaling with multiple worker containers
|
504
|
-
- **🛡️ Error Handling** - Built-in retry logic and dead letter queues
|
505
|
-
- **📊 Monitoring** - Integration with Django admin for task monitoring
|
506
|
-
- **⚡ Performance** - Optimized Redis configuration for high throughput
|
507
|
-
|
508
|
-
#### Real-World Example
|
509
|
-
```python
|
510
|
-
# Document processing pipeline
|
511
|
-
@dramatiq.actor(queue_name="knowledge", max_retries=2)
|
512
|
-
def process_document_async(document_id: str) -> dict:
|
513
|
-
"""Complete document processing with chunking and embeddings."""
|
514
|
-
try:
|
515
|
-
document = Document.objects.get(id=document_id)
|
516
|
-
|
517
|
-
# Step 1: Chunk document
|
518
|
-
chunks = create_document_chunks(document)
|
519
|
-
|
520
|
-
# Step 2: Generate embeddings
|
521
|
-
for chunk in chunks:
|
522
|
-
generate_embeddings.send(chunk.id)
|
523
|
-
|
524
|
-
# Step 3: Optimize database
|
525
|
-
optimize_document_embeddings.send(document_id)
|
526
|
-
|
527
|
-
return {"status": "completed", "chunks_created": len(chunks)}
|
528
|
-
|
529
|
-
except Exception as e:
|
530
|
-
logger.error(f"Document processing failed: {e}")
|
531
|
-
return {"status": "failed", "error": str(e)}
|
532
|
-
|
533
|
-
# Triggered automatically via Django signals
|
534
|
-
@receiver(post_save, sender=Document)
|
535
|
-
def queue_document_processing(sender, instance, created, **kwargs):
|
536
|
-
if created:
|
537
|
-
process_document_async.send(str(instance.id))
|
538
|
-
```
|
539
|
-
|
540
|
-
**Perfect for:**
|
541
|
-
- 📄 **Document Processing** - PDF parsing, text extraction, embeddings
|
542
|
-
- 📧 **Email Campaigns** - Bulk email sending with delivery tracking
|
543
|
-
- 🔄 **Data Synchronization** - API integrations and data imports
|
544
|
-
- 📊 **Report Generation** - Heavy computational tasks
|
545
|
-
- 🧹 **Cleanup Tasks** - Database maintenance and optimization
|
546
|
-
|
547
|
-
---
|
548
|
-
|
549
|
-
## 🛠️ Management Commands (CLI Tools)
|
550
|
-
|
551
|
-
Django-CFG includes powerful management commands for development and operations:
|
552
|
-
|
553
|
-
### 🗄️ Database & Migration Commands
|
554
|
-
| Command | Description | Example |
|
555
|
-
|---------|-------------|---------|
|
556
|
-
| **`migrator`** | Interactive database migration tool with multi-DB support | `python manage.py migrator --auto` |
|
557
|
-
| **`migrate_all`** | Simple migration command for all databases (production-ready) | `python manage.py migrate_all --dry-run` |
|
558
|
-
|
559
|
-
**Migration Command Details:**
|
560
|
-
- **`migrator`** - Full-featured migration tool with interactive menu, database status, and diagnostics
|
561
|
-
- `python manage.py migrator` - Interactive menu with all options
|
562
|
-
- `python manage.py migrator --auto` - Automatic migration of all databases
|
563
|
-
- `python manage.py migrator --database vehicles` - Migrate specific database only
|
564
|
-
- `python manage.py migrator --app vehicles_data` - Migrate specific app across all databases
|
565
|
-
- **`migrate_all`** - Simplified migration tool optimized for production and CI/CD
|
566
|
-
- `python manage.py migrate_all` - Migrate all databases automatically
|
567
|
-
- `python manage.py migrate_all --dry-run` - Show what would be migrated without executing
|
568
|
-
- `python manage.py migrate_all --skip-makemigrations` - Skip makemigrations step
|
569
|
-
|
570
|
-
### 🔧 Configuration & Validation Commands
|
571
|
-
| Command | Description | Example |
|
572
|
-
|---------|-------------|---------|
|
573
|
-
| **`check_settings`** | Validate configuration and settings | `python manage.py check_settings` |
|
574
|
-
| **`show_config`** | Display current configuration | `python manage.py show_config --format yaml` |
|
575
|
-
| **`validate_config`** | Deep validation of all settings | `python manage.py validate_config --strict` |
|
576
|
-
| **`tree`** | Display Django project structure | `python manage.py tree --depth 3 --include-docs` |
|
577
|
-
|
578
|
-
### 🚀 API & Development Commands
|
579
|
-
| Command | Description | Example |
|
580
|
-
|---------|-------------|---------|
|
581
|
-
| **`create_token`** | Generate API tokens and keys | `python manage.py create_token --user admin` |
|
582
|
-
| **`generate`** | Generate API clients and documentation | `python manage.py generate --zone client` |
|
583
|
-
| **`show_urls`** | Display all URL patterns | `python manage.py show_urls --zone client` |
|
584
|
-
| **`script`** | Run custom scripts with Django context | `python manage.py script my_script.py` |
|
585
|
-
| **`runserver_ngrok`** | Run development server with ngrok tunnel | `python manage.py runserver_ngrok --domain custom` |
|
586
|
-
|
587
|
-
### 👤 User & Authentication Commands
|
588
|
-
| Command | Description | Example |
|
589
|
-
|---------|-------------|---------|
|
590
|
-
| **`superuser`** | Create superuser with smart defaults | `python manage.py superuser --email admin@example.com` |
|
591
|
-
|
592
|
-
### 📧 Communication & Integration Commands
|
593
|
-
| Command | Description | Example |
|
594
|
-
|---------|-------------|---------|
|
595
|
-
| **`test_email`** | Test email configuration | `python manage.py test_email --to test@example.com` |
|
596
|
-
| **`test_telegram`** | Test Telegram bot integration | `python manage.py test_telegram --chat_id 123` |
|
597
|
-
| **`test_twilio`** | Test Twilio SMS and WhatsApp integration | `python manage.py test_twilio` |
|
598
|
-
| **`translate_content`** | Translate JSON with LLM and smart caching | `python manage.py translate_content --target-lang es` |
|
599
|
-
|
600
|
-
### 🎫 Built-in Module Commands
|
601
|
-
| Command | Description | Example |
|
602
|
-
|---------|-------------|---------|
|
603
|
-
| **`support_stats`** | Display support ticket statistics | `python manage.py support_stats --format json` |
|
604
|
-
| **`test_newsletter`** | Test newsletter sending functionality | `python manage.py test_newsletter --email test@example.com` |
|
605
|
-
| **`newsletter_stats`** | Display newsletter campaign statistics | `python manage.py newsletter_stats --format json` |
|
606
|
-
| **`leads_stats`** | Display lead conversion statistics | `python manage.py leads_stats --format json` |
|
607
|
-
|
608
|
-
### 🔄 Background Task Commands
|
609
|
-
| Command | Description | Example |
|
610
|
-
|---------|-------------|---------|
|
611
|
-
| **`rundramatiq`** | Run Dramatiq background task workers | `python manage.py rundramatiq --processes 4` |
|
612
|
-
| **`task_status`** | Show Dramatiq task status and queues | `python manage.py task_status --queue high` |
|
613
|
-
| **`task_clear`** | Clear Dramatiq queues | `python manage.py task_clear --queue default` |
|
614
|
-
| **`test_tasks`** | Test Dramatiq task processing pipeline | `python manage.py test_tasks --document-id 123` |
|
615
|
-
|
616
|
-
---
|
617
|
-
|
618
|
-
## 🌍 Environment Detection
|
619
|
-
|
620
|
-
Django-CFG automatically detects your environment and applies appropriate settings:
|
621
|
-
|
622
|
-
| Environment | Detection Method | Cache Backend | Email Backend | Database SSL | Debug Mode |
|
623
|
-
|-------------|------------------|---------------|---------------|--------------|------------|
|
624
|
-
| **Development** | `DEBUG=True` or local domains | Memory/Redis | Console | Optional | `True` |
|
625
|
-
| **Testing** | `pytest` or `test` in command | Dummy Cache | In-Memory | Disabled | `False` |
|
626
|
-
| **Staging** | `STAGING=True` or staging domains | Redis | SMTP | Required | `False` |
|
627
|
-
| **Production** | `PRODUCTION=True` or prod domains | Redis | SMTP | Required | `False` |
|
628
|
-
|
629
|
-
---
|
630
|
-
|
631
|
-
## 📝 Logging System
|
632
|
-
|
633
|
-
Comprehensive logging with environment-aware configuration:
|
634
|
-
|
635
|
-
```python
|
636
|
-
# Automatic log configuration based on environment
|
637
|
-
LOGGING = {
|
638
|
-
'version': 1,
|
639
|
-
'disable_existing_loggers': False,
|
640
|
-
'formatters': {
|
641
|
-
'verbose': {
|
642
|
-
'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
|
643
|
-
'style': '{',
|
644
|
-
},
|
645
|
-
'simple': {
|
646
|
-
'format': '{levelname} {message}',
|
647
|
-
'style': '{',
|
648
|
-
},
|
649
|
-
},
|
650
|
-
'handlers': {
|
651
|
-
'file': {
|
652
|
-
'level': 'INFO',
|
653
|
-
'class': 'logging.FileHandler',
|
654
|
-
'filename': 'django.log',
|
655
|
-
'formatter': 'verbose',
|
656
|
-
},
|
657
|
-
'console': {
|
658
|
-
'level': 'DEBUG',
|
659
|
-
'class': 'logging.StreamHandler',
|
660
|
-
'formatter': 'simple',
|
661
|
-
},
|
662
|
-
},
|
663
|
-
'root': {
|
664
|
-
'handlers': ['console', 'file'],
|
665
|
-
'level': 'INFO',
|
666
|
-
},
|
667
|
-
}
|
668
|
-
```
|
669
|
-
|
670
|
-
**Features:**
|
671
|
-
- Environment-specific log levels
|
672
|
-
- Automatic file rotation
|
673
|
-
- Structured logging with JSON support
|
674
|
-
- Integration with monitoring systems
|
675
|
-
- Custom formatters for different outputs
|
676
|
-
|
677
|
-
---
|
678
|
-
|
679
|
-
## 📚 API Documentation
|
680
|
-
|
681
|
-
Django-CFG provides ready-made Redoc/Swagger solutions for each API zone:
|
682
|
-
|
683
|
-
### Zone-Based API Architecture
|
684
|
-
```python
|
685
|
-
revolution: RevolutionConfig = RevolutionConfig(
|
686
|
-
zones={
|
687
|
-
"client": ZoneConfig(
|
688
|
-
apps=["accounts", "billing"],
|
689
|
-
title="Client API",
|
690
|
-
public=True,
|
691
|
-
),
|
692
|
-
"admin": ZoneConfig(
|
693
|
-
apps=["management", "reports"],
|
694
|
-
title="Admin API",
|
695
|
-
auth_required=True,
|
696
|
-
),
|
697
|
-
}
|
698
|
-
)
|
699
|
-
```
|
700
|
-
|
701
|
-
### Automatic Documentation URLs
|
702
|
-
- **`/api/client/docs/`** - Interactive Swagger UI for client zone
|
703
|
-
- **`/api/client/redoc/`** - Beautiful ReDoc documentation
|
704
|
-
- **`/api/admin/docs/`** - Admin zone Swagger UI
|
705
|
-
- **`/api/admin/redoc/`** - Admin zone ReDoc
|
706
|
-
|
707
|
-
### Client Generation
|
708
|
-
```bash
|
709
|
-
# Generate TypeScript client for client zone
|
710
|
-
python manage.py generate --zone client --format typescript
|
711
|
-
|
712
|
-
# Generate Python client for admin zone
|
713
|
-
python manage.py generate --zone admin --format python
|
714
|
-
```
|
715
|
-
|
716
|
-
---
|
717
|
-
|
718
|
-
## 🎫 Built-in Support System
|
719
|
-
|
720
|
-
Django-CFG includes a complete support ticket system with modern chat interface:
|
721
|
-
|
722
|
-
### Features
|
723
|
-
- **🎯 Ticket Management** - Create, assign, and track support tickets
|
724
|
-
- **💬 Chat Interface** - Beautiful Tailwind CSS chat UI for conversations
|
725
|
-
- **📧 Email Integration** - Automatic notifications for ticket updates
|
726
|
-
- **👥 User Management** - Support for both staff and customer interactions
|
727
|
-
- **📊 Dashboard Integration** - Real-time metrics in Unfold admin
|
728
|
-
- **🔗 API Ready** - RESTful API endpoints for all support operations
|
729
|
-
|
730
|
-
### Quick Setup
|
731
|
-
```python
|
732
|
-
from django_cfg import DjangoConfig
|
733
|
-
|
734
|
-
class MyConfig(DjangoConfig):
|
735
|
-
project_name: str = "My App"
|
736
|
-
enable_support: bool = True # That's it!
|
737
|
-
|
738
|
-
config = MyConfig()
|
739
|
-
```
|
740
|
-
|
741
|
-
### Automatic Integration
|
742
|
-
- ✅ **Admin Interface** - Support section in sidebar with tickets & messages
|
743
|
-
- ✅ **Dashboard Cards** - Live ticket statistics and quick actions
|
744
|
-
- ✅ **API Endpoints** - `/api/support/` zone with full CRUD operations
|
745
|
-
- ✅ **Email Templates** - Beautiful HTML emails with your branding
|
746
|
-
- ✅ **Chat Interface** - Modern `/support/chat/{ticket_uuid}/` pages
|
747
|
-
|
748
|
-
### Disable Support (Optional)
|
749
|
-
```python
|
750
|
-
enable_support: bool = False # Removes from admin, API, and dashboard
|
751
|
-
```
|
752
|
-
|
753
|
-
---
|
754
|
-
|
755
|
-
## 📧 Built-in Newsletter System
|
756
|
-
|
757
|
-
Django-CFG includes a complete newsletter and email marketing system with tracking and analytics:
|
758
|
-
|
759
|
-
### Features
|
760
|
-
- **📬 Newsletter Management** - Create, schedule, and manage email newsletters
|
761
|
-
- **👥 Subscription Management** - User subscriptions with double opt-in and unsubscribe
|
762
|
-
- **📊 Email Tracking** - Open rates, click tracking, and engagement analytics
|
763
|
-
- **🎯 Campaign System** - Organize newsletters into campaigns with templates
|
764
|
-
- **📈 Bulk Email** - Send to thousands of subscribers with delivery tracking
|
765
|
-
- **🔗 API Ready** - RESTful API endpoints for all newsletter operations
|
766
|
-
- **📱 Email Templates** - Beautiful responsive HTML templates with tracking pixels
|
767
|
-
|
768
|
-
### Quick Setup
|
769
|
-
```python
|
770
|
-
from django_cfg import DjangoConfig
|
771
|
-
|
772
|
-
class MyConfig(DjangoConfig):
|
773
|
-
project_name: str = "My App"
|
774
|
-
enable_newsletter: bool = True # That's it!
|
775
|
-
|
776
|
-
config = MyConfig()
|
777
|
-
```
|
778
|
-
|
779
|
-
### Automatic Integration
|
780
|
-
- ✅ **Admin Interface** - Newsletter section with campaigns, subscriptions & email logs
|
781
|
-
- ✅ **Dashboard Cards** - Live newsletter statistics and recent campaigns
|
782
|
-
- ✅ **API Endpoints** - `/api/newsletter/` zone with full CRUD operations
|
783
|
-
- ✅ **Email Templates** - Responsive HTML emails with your branding and tracking
|
784
|
-
- ✅ **Tracking System** - Automatic open/click tracking with UUID-based security
|
785
|
-
- ✅ **Subscription Forms** - Ready-to-use subscription and unsubscribe endpoints
|
786
|
-
|
787
|
-
### Email Tracking Features
|
788
|
-
```python
|
789
|
-
from django_cfg.apps.newsletter.services.email_service import NewsletterEmailService
|
790
|
-
|
791
|
-
# Send newsletter with tracking
|
792
|
-
service = NewsletterEmailService()
|
793
|
-
result = service.send_newsletter_email(
|
794
|
-
newsletter=newsletter,
|
795
|
-
subject="Monthly Update",
|
796
|
-
email_title="Our Latest News",
|
797
|
-
main_text="Check out what's new this month!",
|
798
|
-
button_text="Read More",
|
799
|
-
button_url="https://example.com/news",
|
800
|
-
send_to_all=True # Send to all subscribers
|
801
|
-
)
|
802
|
-
```
|
803
|
-
|
804
|
-
### Disable Newsletter (Optional)
|
805
|
-
```python
|
806
|
-
enable_newsletter: bool = False # Removes from admin, API, and dashboard
|
807
|
-
```
|
808
|
-
|
809
|
-
---
|
810
|
-
|
811
|
-
## 🎯 Built-in Lead Management System
|
812
|
-
|
813
|
-
Django-CFG includes a comprehensive lead collection and CRM system for capturing and managing potential customers:
|
814
|
-
|
815
|
-
### Features
|
816
|
-
- **📝 Lead Capture** - Collect leads from contact forms, landing pages, and API
|
817
|
-
- **🏷️ Lead Sources** - Track where leads came from (web, mobile, ads, referrals)
|
818
|
-
- **📊 Lead Scoring** - Automatic scoring based on engagement and profile data
|
819
|
-
- **🔄 Status Management** - Lead lifecycle from new to converted or closed
|
820
|
-
- **📧 Email Integration** - Automatic notifications for new leads and status changes
|
821
|
-
- **📱 API Ready** - RESTful API endpoints for all lead operations
|
822
|
-
- **🎯 CRM Integration** - Ready for integration with external CRM systems
|
823
|
-
|
824
|
-
### Quick Setup
|
825
|
-
```python
|
826
|
-
from django_cfg import DjangoConfig
|
827
|
-
|
828
|
-
class MyConfig(DjangoConfig):
|
829
|
-
project_name: str = "My App"
|
830
|
-
enable_leads: bool = True # That's it!
|
831
|
-
|
832
|
-
config = MyConfig()
|
833
|
-
```
|
834
|
-
|
835
|
-
### Automatic Integration
|
836
|
-
- ✅ **Admin Interface** - Leads section with lead management and source tracking
|
837
|
-
- ✅ **Dashboard Cards** - Live lead statistics and conversion metrics
|
838
|
-
- ✅ **API Endpoints** - `/api/leads/` zone with full CRUD operations
|
839
|
-
- ✅ **Contact Forms** - Ready-to-use lead capture forms and endpoints
|
840
|
-
- ✅ **Email Notifications** - Automatic alerts for new leads and status changes
|
841
|
-
- ✅ **Source Tracking** - Automatic detection of lead sources and campaigns
|
842
|
-
|
843
|
-
### Lead Capture Example
|
844
|
-
```python
|
845
|
-
from django_cfg.apps.leads.models import Lead, LeadSource
|
846
|
-
|
847
|
-
# Create lead from contact form
|
848
|
-
lead = Lead.objects.create(
|
849
|
-
name="John Doe",
|
850
|
-
email="john@example.com",
|
851
|
-
phone="+1234567890",
|
852
|
-
message="Interested in your services",
|
853
|
-
source=LeadSource.objects.get(name="Website Contact Form"),
|
854
|
-
status=Lead.LeadStatus.NEW
|
855
|
-
)
|
856
|
-
```
|
857
|
-
|
858
|
-
### Disable Leads (Optional)
|
859
|
-
```python
|
860
|
-
enable_leads: bool = False # Removes from admin, API, and dashboard
|
861
|
-
```
|
862
|
-
|
863
|
-
---
|
864
|
-
|
865
|
-
## 👤 Built-in User Management System
|
866
|
-
|
867
|
-
Django-CFG includes a comprehensive user management system with OTP authentication, profiles, and activity tracking:
|
868
|
-
|
869
|
-
### Features
|
870
|
-
- **🔐 Multi-Channel OTP Authentication** - Secure one-time password authentication via email and SMS
|
871
|
-
- **📱 Phone Number Support** - Complete phone verification with Twilio SMS integration
|
872
|
-
- **👥 Custom User Model** - Extended user model with profiles and metadata
|
873
|
-
- **📊 Activity Tracking** - Complete audit trail of user actions and logins
|
874
|
-
- **🔗 Registration Sources** - Track where users came from (web, mobile, API, etc.)
|
875
|
-
- **📧 Email Integration** - Beautiful welcome emails and OTP notifications
|
876
|
-
- **💬 SMS Integration** - Twilio-powered SMS delivery for phone verification
|
877
|
-
- **🛡️ Security Features** - Failed attempt tracking, account lockouts, and audit logs
|
878
|
-
- **📱 API Ready** - RESTful API endpoints for all user operations
|
879
|
-
|
880
|
-
### Quick Setup
|
881
|
-
```python
|
882
|
-
from django_cfg import DjangoConfig
|
883
|
-
|
884
|
-
class MyConfig(DjangoConfig):
|
885
|
-
project_name: str = "My App"
|
886
|
-
enable_accounts: bool = True # That's it!
|
887
|
-
# auth_user_model is automatically set to django_cfg_accounts.CustomUser
|
888
|
-
|
889
|
-
config = MyConfig()
|
890
|
-
```
|
891
|
-
|
892
|
-
### Automatic Integration
|
893
|
-
- ✅ **Custom User Model** - Automatically sets `AUTH_USER_MODEL` to `django_cfg_accounts.CustomUser`
|
894
|
-
- ✅ **Admin Interface** - "Users & Access" section with users, groups, and registration sources
|
895
|
-
- ✅ **Dashboard Integration** - User statistics and recent activity widgets
|
896
|
-
- ✅ **API Endpoints** - `/api/accounts/` zone with authentication, profiles, and OTP
|
897
|
-
- ✅ **Email Templates** - Welcome emails and OTP verification with your branding
|
898
|
-
- ✅ **Migration Safety** - Smart migration ordering to avoid conflicts
|
899
|
-
|
900
|
-
### Multi-Channel OTP Authentication Flow
|
901
|
-
```python
|
902
|
-
from django_cfg.apps.accounts.services.otp_service import OTPService
|
903
|
-
|
904
|
-
# Email OTP (traditional)
|
905
|
-
success, error = OTPService.request_email_otp("user@example.com")
|
906
|
-
user = OTPService.verify_email_otp("user@example.com", "123456")
|
907
|
-
|
908
|
-
# Phone OTP (SMS via Twilio)
|
909
|
-
success, error = OTPService.request_phone_otp("+1234567890")
|
910
|
-
user = OTPService.verify_phone_otp("+1234567890", "123456")
|
911
|
-
|
912
|
-
# Auto-detect channel (unified API)
|
913
|
-
success, error = OTPService.request_otp("user@example.com") # Email
|
914
|
-
success, error = OTPService.request_otp("+1234567890") # Phone
|
915
|
-
```
|
916
|
-
|
917
|
-
### Twilio SMS Configuration
|
918
|
-
```yaml
|
919
|
-
# config.dev.yaml
|
920
|
-
twilio:
|
921
|
-
account_sid: "your-twilio-account-sid"
|
922
|
-
auth_token: "your-twilio-auth-token"
|
923
|
-
sms_from: "+1234567890" # Your Twilio phone number
|
924
|
-
whatsapp_from: "+14155238886" # WhatsApp sandbox (optional)
|
925
|
-
```
|
926
|
-
|
927
|
-
### Custom User Model Features
|
928
|
-
- **Extended Profile** - Additional fields for user metadata including phone numbers
|
929
|
-
- **Phone Verification** - Built-in phone verification with SMS OTP
|
930
|
-
- **Activity Tracking** - Automatic logging of user actions and authentication events
|
931
|
-
- **Registration Sources** - Track user acquisition channels (email vs phone signup)
|
932
|
-
- **Security Audit** - Failed login attempts and security events
|
933
|
-
|
934
|
-
### Disable Accounts (Optional)
|
935
|
-
```python
|
936
|
-
enable_accounts: bool = False # Uses Django's default User model
|
937
|
-
```
|
938
|
-
|
939
|
-
---
|
940
|
-
|
941
|
-
## 🤖 Built-in LLM Integration
|
942
|
-
|
943
|
-
Django-CFG includes a powerful LLM module for AI-powered features like translation, content generation, and smart automation:
|
944
|
-
|
945
|
-
### Features
|
946
|
-
- **🌍 Smart Translation** - JSON translation with intelligent caching by language pairs
|
947
|
-
- **💬 LLM Client** - OpenAI/OpenRouter integration with dynamic pricing and cost tracking
|
948
|
-
- **⚡ Smart Caching** - Text-level caching that sends only uncached content to LLM
|
949
|
-
- **🔧 Direct Injection** - No configuration needed, just inject `LLMClient` where needed
|
950
|
-
- **📊 Cost Tracking** - Real-time cost calculation with dynamic model pricing
|
951
|
-
- **🛡️ Production Ready** - Built-in error handling, retries, and fallbacks
|
952
|
-
|
953
|
-
### Quick Usage
|
954
|
-
```python
|
955
|
-
from django_cfg.modules.django_llm import LLMClient, DjangoTranslator
|
956
|
-
|
957
|
-
# Direct LLM usage
|
958
|
-
client = LLMClient(provider="openrouter", api_key="your-key")
|
959
|
-
response = client.chat_completion([{"role": "user", "content": "Hello!"}])
|
960
|
-
|
961
|
-
# Smart JSON translation with caching
|
962
|
-
translator = DjangoTranslator(client=client)
|
963
|
-
translated = translator.translate_json(
|
964
|
-
data={"greeting": "Hello", "message": "Welcome to our app"},
|
965
|
-
target_language="es"
|
966
|
-
)
|
967
|
-
# Result: {"greeting": "Hola", "message": "Bienvenido a nuestra aplicación"}
|
968
|
-
```
|
969
|
-
|
970
|
-
### Management Command
|
971
|
-
```bash
|
972
|
-
# Translate JSON content with smart caching
|
973
|
-
python manage.py translate_content --target-lang es --json '{"title": "Hello World"}'
|
974
|
-
```
|
975
|
-
|
976
|
-
### Key Benefits
|
977
|
-
- **Zero Configuration** - Works out of the box with environment variables
|
978
|
-
- **Smart Caching** - Dramatically reduces LLM costs with intelligent text-level caching
|
979
|
-
- **Language Detection** - Automatic source language detection for better translations
|
980
|
-
- **Cost Optimization** - Only sends uncached texts to LLM, reuses cached translations
|
981
|
-
|
982
|
-
---
|
983
|
-
|
984
|
-
## 🌐 Built-in Ngrok Integration
|
985
|
-
|
986
|
-
Django-CFG includes seamless ngrok integration for instant webhook testing and external API development:
|
987
|
-
|
988
|
-
### Features
|
989
|
-
- **🚀 Zero Configuration** - Works out of the box with automatic tunnel creation
|
990
|
-
- **🔐 Secure Tunnels** - HTTPS tunnels with automatic ALLOWED_HOSTS management
|
991
|
-
- **⚡ Auto URL Updates** - Automatically updates `api_url` when tunnel is active
|
992
|
-
- **🎯 Webhook Ready** - Perfect for testing webhooks, APIs, and external integrations
|
993
|
-
- **🛠️ Development Focused** - Only enabled in DEBUG mode for safety
|
994
|
-
- **📱 Custom Domains** - Support for custom ngrok domains and subdomains
|
995
|
-
|
996
|
-
### Quick Setup
|
997
|
-
```python
|
998
|
-
from django_cfg import DjangoConfig
|
999
|
-
from django_cfg.models.ngrok import NgrokConfig, NgrokAuthConfig, NgrokTunnelConfig
|
1000
|
-
|
1001
|
-
class MyConfig(DjangoConfig):
|
1002
|
-
project_name: str = "My App"
|
1003
|
-
debug: bool = True
|
1004
|
-
|
1005
|
-
# Ngrok configuration (optional)
|
1006
|
-
ngrok: Optional[NgrokConfig] = NgrokConfig(
|
1007
|
-
enabled=True,
|
1008
|
-
auth=NgrokAuthConfig(
|
1009
|
-
authtoken="your-ngrok-authtoken", # Get from ngrok.com
|
1010
|
-
),
|
1011
|
-
tunnel=NgrokTunnelConfig(
|
1012
|
-
schemes=["https"], # HTTPS for webhooks
|
1013
|
-
compression=True,
|
1014
|
-
),
|
1015
|
-
auto_start=True, # Start with runserver_ngrok
|
1016
|
-
update_api_url=True, # Update api_url automatically
|
1017
|
-
webhook_path="/webhooks/", # Default webhook path
|
1018
|
-
)
|
1019
|
-
|
1020
|
-
config = MyConfig()
|
1021
|
-
```
|
1022
|
-
|
1023
|
-
### Usage
|
1024
|
-
```bash
|
1025
|
-
# Run development server with ngrok tunnel
|
1026
|
-
python manage.py runserver_ngrok
|
1027
|
-
|
1028
|
-
# With custom domain
|
1029
|
-
python manage.py runserver_ngrok --domain myapp
|
1030
|
-
|
1031
|
-
# With custom port
|
1032
|
-
python manage.py runserver_ngrok 0.0.0.0:8080
|
1033
|
-
|
1034
|
-
# Disable ngrok for this session
|
1035
|
-
python manage.py runserver_ngrok --no-ngrok
|
1036
|
-
```
|
1037
|
-
|
1038
|
-
### Automatic Features
|
1039
|
-
- ✅ **HTTPS Tunnel** - Secure tunnel with automatic SSL
|
1040
|
-
- ✅ **ALLOWED_HOSTS** - Automatically adds ngrok domain to Django settings
|
1041
|
-
- ✅ **API URL Updates** - Updates `api_url` config to tunnel URL
|
1042
|
-
- ✅ **Webhook URLs** - Easy webhook URL generation with `get_webhook_url()`
|
1043
|
-
- ✅ **Development Safety** - Only works in DEBUG mode
|
1044
|
-
- ✅ **Error Handling** - Graceful fallback if ngrok is unavailable
|
1045
|
-
|
1046
|
-
### Webhook Testing Example
|
1047
|
-
```python
|
1048
|
-
from django_cfg.modules.django_ngrok import get_ngrok_service
|
1049
|
-
|
1050
|
-
# Get webhook URL for external services
|
1051
|
-
ngrok_service = get_ngrok_service()
|
1052
|
-
webhook_url = ngrok_service.get_webhook_url("stripe/webhook/")
|
1053
|
-
# Result: https://abc123.ngrok-free.app/webhooks/stripe/webhook/
|
1054
|
-
|
1055
|
-
# Use this URL in external service configuration (Stripe, GitHub, etc.)
|
1056
|
-
```
|
1057
|
-
|
1058
|
-
### Environment Configuration
|
1059
|
-
```yaml
|
1060
|
-
# config.dev.yaml
|
1061
|
-
ngrok:
|
1062
|
-
authtoken: "your-ngrok-authtoken-here"
|
1063
|
-
```
|
1064
|
-
|
1065
|
-
**Perfect for:**
|
1066
|
-
- 🎯 **Webhook Development** - Test Stripe, GitHub, Slack webhooks locally
|
1067
|
-
- 🔗 **API Integration** - Share your local API with external services
|
1068
|
-
- 📱 **Mobile Testing** - Test your API from mobile devices
|
1069
|
-
- 🤝 **Client Demos** - Show your work to clients instantly
|
1070
|
-
|
1071
|
-
---
|
1072
|
-
|
1073
|
-
## 🏗️ Real-World Example
|
1074
|
-
|
1075
|
-
Here's a complete production configuration:
|
1076
|
-
|
1077
|
-
```python
|
1078
|
-
from django_cfg import DjangoConfig, DatabaseConfig, UnfoldConfig, RevolutionConfig
|
1079
|
-
|
1080
|
-
class ProductionConfig(DjangoConfig):
|
1081
|
-
"""🚀 Production-ready configuration"""
|
1082
|
-
|
1083
|
-
# === Project Settings ===
|
1084
|
-
project_name: str = "CarAPIS"
|
1085
|
-
project_version: str = "2.0.0"
|
1086
|
-
secret_key: str = env.secret_key
|
1087
|
-
debug: bool = False
|
1088
|
-
|
1089
|
-
# === Multi-Database Setup ===
|
1090
|
-
databases: dict[str, DatabaseConfig] = {
|
1091
|
-
"default": DatabaseConfig(
|
1092
|
-
engine="django.db.backends.postgresql",
|
1093
|
-
name="carapis_main",
|
1094
|
-
user=env.db_user,
|
1095
|
-
password=env.db_password,
|
1096
|
-
host=env.db_host,
|
1097
|
-
port=5432,
|
1098
|
-
sslmode="require",
|
1099
|
-
),
|
1100
|
-
"analytics": DatabaseConfig(
|
1101
|
-
engine="django.db.backends.postgresql",
|
1102
|
-
name="carapis_analytics",
|
1103
|
-
user=env.db_user,
|
1104
|
-
password=env.db_password,
|
1105
|
-
host=env.db_host,
|
1106
|
-
routing_apps=["analytics", "reports"],
|
1107
|
-
),
|
1108
|
-
}
|
1109
|
-
|
1110
|
-
# === Beautiful Admin ===
|
1111
|
-
unfold: UnfoldConfig = UnfoldConfig(
|
1112
|
-
site_title="CarAPIS Admin",
|
1113
|
-
site_header="CarAPIS Control Center",
|
1114
|
-
theme="auto",
|
1115
|
-
dashboard_callback="api.dashboard.main_callback",
|
1116
|
-
)
|
1117
|
-
|
1118
|
-
# === Built-in Modules ===
|
1119
|
-
enable_support: bool = True # Automatic tickets, chat interface, email notifications
|
1120
|
-
enable_accounts: bool = True # Advanced user management with OTP authentication
|
1121
|
-
enable_newsletter: bool = True # Email marketing, campaigns, tracking & analytics
|
1122
|
-
enable_leads: bool = True # Lead capture, CRM integration, source tracking
|
1123
|
-
|
1124
|
-
# === Background Task Processing ===
|
1125
|
-
redis_url: str = "redis://redis:6379/2" # Separate DB for Dramatiq tasks
|
1126
|
-
dramatiq: DramatiqConfig = DramatiqConfig(
|
1127
|
-
processes=4, # Production worker processes
|
1128
|
-
threads=8, # Threads per process for I/O bound tasks
|
1129
|
-
redis_db=2, # Dedicated Redis DB for task queues
|
1130
|
-
queues=["default", "high", "low", "knowledge", "email"], # Production queues
|
1131
|
-
max_retries=3, # Default retry attempts
|
1132
|
-
max_age=3600000, # 1 hour max task age (milliseconds)
|
1133
|
-
)
|
1134
|
-
|
1135
|
-
# === Multi-Zone API ===
|
1136
|
-
revolution: RevolutionConfig = RevolutionConfig(
|
1137
|
-
api_prefix="api/v2",
|
1138
|
-
zones={
|
1139
|
-
"public": ZoneConfig(
|
1140
|
-
apps=["cars", "search"],
|
1141
|
-
title="Public API",
|
1142
|
-
description="Car data and search",
|
1143
|
-
public=True,
|
1144
|
-
),
|
1145
|
-
"partner": ZoneConfig(
|
1146
|
-
apps=["integrations", "webhooks"],
|
1147
|
-
title="Partner API",
|
1148
|
-
auth_required=True,
|
1149
|
-
rate_limit="1000/hour",
|
1150
|
-
),
|
1151
|
-
}
|
1152
|
-
)
|
1153
|
-
|
1154
|
-
config = ProductionConfig()
|
1155
|
-
```
|
1156
|
-
|
1157
|
-
---
|
1158
|
-
|
1159
|
-
## 🧪 Testing
|
1160
|
-
|
1161
|
-
Django-CFG includes comprehensive testing utilities:
|
1162
|
-
|
1163
|
-
```python
|
1164
|
-
def test_configuration():
|
1165
|
-
"""Test your configuration is valid"""
|
1166
|
-
config = MyConfig()
|
1167
|
-
settings = config.get_all_settings()
|
1168
|
-
|
1169
|
-
# Validate required settings
|
1170
|
-
assert "SECRET_KEY" in settings
|
1171
|
-
assert settings["DEBUG"] is False
|
1172
|
-
assert "myapp" in settings["INSTALLED_APPS"]
|
1173
|
-
|
1174
|
-
# Test database connections
|
1175
|
-
assert "default" in settings["DATABASES"]
|
1176
|
-
assert settings["DATABASES"]["default"]["ENGINE"] == "django.db.backends.postgresql"
|
1177
|
-
|
1178
|
-
# Validate API configuration
|
1179
|
-
assert "SPECTACULAR_SETTINGS" in settings
|
1180
|
-
assert settings["SPECTACULAR_SETTINGS"]["TITLE"] == "My API"
|
1181
|
-
```
|
1182
|
-
|
1183
|
-
---
|
1184
|
-
|
1185
|
-
## 🔄 Migrating Existing Django Projects
|
1186
|
-
|
1187
|
-
### Option 1: Start Fresh (Recommended)
|
1188
|
-
```bash
|
1189
|
-
# Create new project with Django-CFG
|
1190
|
-
django-cfg create-project "My Migrated Project"
|
1191
|
-
|
1192
|
-
# Copy your apps and models to the new structure
|
1193
|
-
# Migrate your data using Django's dumpdata/loaddata
|
1194
|
-
```
|
1195
|
-
|
1196
|
-
### Option 2: Gradual Migration
|
1197
|
-
```bash
|
1198
|
-
# Install Django-CFG in existing project
|
1199
|
-
pip install django-cfg
|
1200
|
-
|
1201
|
-
# Create configuration class
|
1202
|
-
# config.py
|
1203
|
-
from django_cfg import DjangoConfig
|
1204
|
-
|
1205
|
-
class MyConfig(DjangoConfig):
|
1206
|
-
project_name: str = "Existing Project"
|
1207
|
-
secret_key: str = "your-existing-secret"
|
1208
|
-
project_apps: list[str] = ["your_app1", "your_app2"]
|
1209
|
-
|
1210
|
-
config = MyConfig()
|
1211
|
-
```
|
1212
|
-
|
1213
|
-
```python
|
1214
|
-
# Replace your settings.py content with:
|
1215
|
-
from .config import config
|
1216
|
-
globals().update(config.get_all_settings())
|
1217
|
-
```
|
1218
|
-
|
1219
|
-
### Option 3: Side-by-Side Comparison
|
1220
|
-
```bash
|
1221
|
-
# Create reference project to compare
|
1222
|
-
django-cfg create-project "Reference Project"
|
1223
|
-
|
1224
|
-
# Compare configurations and gradually adopt features
|
1225
|
-
# Perfect for learning Django-CFG patterns
|
1226
|
-
```
|
1227
|
-
|
1228
|
-
**Result:** Transform your legacy Django project into a modern, type-safe, feature-rich application! 🎉
|
1229
|
-
|
1230
|
-
---
|
1231
|
-
|
1232
|
-
## 🤝 Contributing
|
1233
|
-
|
1234
|
-
We welcome contributions! Here's how to get started:
|
1235
|
-
|
1236
|
-
```bash
|
1237
|
-
git clone https://github.com/markolofsen/django-cfg.git
|
1238
|
-
cd django-cfg
|
1239
|
-
poetry install
|
1240
|
-
poetry run pytest
|
1241
|
-
```
|
1242
|
-
|
1243
|
-
### Development Commands
|
1244
|
-
```bash
|
1245
|
-
# Run tests
|
1246
|
-
poetry run pytest
|
1247
|
-
|
1248
|
-
# Format code
|
1249
|
-
poetry run black .
|
1250
|
-
|
1251
|
-
# Type checking
|
1252
|
-
poetry run mypy .
|
1253
|
-
|
1254
|
-
# Build package
|
1255
|
-
poetry build
|
1256
|
-
```
|
1257
|
-
|
1258
|
-
---
|
1259
|
-
|
1260
|
-
## 📄 License
|
1261
|
-
|
1262
|
-
MIT License - see [LICENSE](LICENSE) file for details.
|
1263
|
-
|
1264
|
-
---
|
1265
|
-
|
1266
|
-
## 🙏 Acknowledgments
|
1267
|
-
|
1268
|
-
- **Django** - The web framework for perfectionists with deadlines
|
1269
|
-
- **Pydantic** - Data validation using Python type hints
|
1270
|
-
- **Django Unfold** - Beautiful modern admin interface
|
1271
|
-
- **Django Revolution** - API generation and zone management
|
1272
|
-
|
1273
|
-
---
|
1274
|
-
|
1275
|
-
**Made with ❤️ by the ReformsAI Team**
|
1276
|
-
|
1277
|
-
*Django-CFG: Because configuration should be simple, safe, and powerful.*
|