django-cfg 1.1.73__py3-none-any.whl → 1.1.74__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 CHANGED
@@ -38,7 +38,7 @@ default_app_config = "django_cfg.apps.DjangoCfgConfig"
38
38
  from typing import TYPE_CHECKING
39
39
 
40
40
  # Version information
41
- __version__ = "1.1.73"
41
+ __version__ = "1.1.74"
42
42
  __author__ = "Unrealos Team"
43
43
  __email__ = "info@unrealos.com"
44
44
  __license__ = "MIT"
@@ -83,8 +83,8 @@ class UserManager(UserManager):
83
83
  f"Attempting to get_or_create user with email: {email}, username: {username}"
84
84
  )
85
85
 
86
- # Create or get user using self.model instead of importing CustomUser
87
- user, created = self.model.objects.get_or_create(
86
+ # Create or get user using self (the manager)
87
+ user, created = self.get_or_create(
88
88
  email=email, defaults=defaults
89
89
  )
90
90
 
@@ -0,0 +1,117 @@
1
+ """
2
+ Simple Migration Command for Django Config Toolkit
3
+ Migrate all databases based on django-cfg configuration.
4
+ """
5
+
6
+ from django.core.management.base import BaseCommand
7
+ from django.core.management import call_command
8
+ from django.apps import apps
9
+
10
+ from django_cfg.core.config import get_current_config
11
+
12
+
13
+ class Command(BaseCommand):
14
+ help = "Migrate all databases based on django-cfg configuration"
15
+
16
+ def add_arguments(self, parser):
17
+ parser.add_argument(
18
+ "--dry-run",
19
+ action="store_true",
20
+ help="Show what would be migrated without executing"
21
+ )
22
+ parser.add_argument(
23
+ "--skip-makemigrations",
24
+ action="store_true",
25
+ help="Skip makemigrations step"
26
+ )
27
+
28
+ def handle(self, *args, **options):
29
+ """Run migrations for all configured databases."""
30
+ dry_run = options.get("dry_run", False)
31
+ skip_makemigrations = options.get("skip_makemigrations", False)
32
+
33
+ if dry_run:
34
+ self.stdout.write(self.style.WARNING("🔍 DRY RUN - No changes will be made"))
35
+
36
+ self.stdout.write(self.style.SUCCESS("🚀 Migrating all databases..."))
37
+
38
+ # Step 1: Create migrations if needed
39
+ if not skip_makemigrations:
40
+ self.stdout.write("📝 Creating migrations...")
41
+ if not dry_run:
42
+ call_command("makemigrations", verbosity=1)
43
+ else:
44
+ self.stdout.write(" Would run: makemigrations")
45
+
46
+ # Step 2: Get database configuration
47
+ try:
48
+ config = get_current_config()
49
+ if not config or not hasattr(config, 'databases'):
50
+ self.stdout.write(self.style.ERROR("❌ No django-cfg configuration found"))
51
+ return
52
+ except Exception as e:
53
+ self.stdout.write(self.style.ERROR(f"❌ Error loading configuration: {e}"))
54
+ return
55
+
56
+ # Step 3: Migrate each database
57
+ for db_name, db_config in config.databases.items():
58
+ self.stdout.write(f"\n🔄 Migrating database: {db_name}")
59
+
60
+ if hasattr(db_config, 'apps') and db_config.apps:
61
+ # Migrate specific apps for this database
62
+ for app_path in db_config.apps:
63
+ app_label = self._get_app_label(app_path)
64
+ if app_label:
65
+ self.stdout.write(f" 📦 Migrating {app_label}...")
66
+ if not dry_run:
67
+ try:
68
+ call_command("migrate", app_label, database=db_name, verbosity=1)
69
+ except Exception as e:
70
+ self.stdout.write(self.style.WARNING(f" ⚠️ Warning: {e}"))
71
+ else:
72
+ self.stdout.write(f" Would run: migrate {app_label} --database={db_name}")
73
+ else:
74
+ # Migrate all apps for this database (usually default)
75
+ self.stdout.write(f" 📦 Migrating all apps...")
76
+ if not dry_run:
77
+ try:
78
+ call_command("migrate", database=db_name, verbosity=1)
79
+ except Exception as e:
80
+ self.stdout.write(self.style.WARNING(f" ⚠️ Warning: {e}"))
81
+ else:
82
+ self.stdout.write(f" Would run: migrate --database={db_name}")
83
+
84
+ # Step 4: Migrate constance if needed
85
+ self.stdout.write(f"\n🔧 Migrating constance...")
86
+ if not dry_run:
87
+ try:
88
+ call_command("migrate", "constance", database="default", verbosity=1)
89
+ except Exception as e:
90
+ self.stdout.write(self.style.WARNING(f"⚠️ Constance warning: {e}"))
91
+ else:
92
+ self.stdout.write(" Would run: migrate constance --database=default")
93
+
94
+ self.stdout.write(self.style.SUCCESS("\n✅ All migrations completed!"))
95
+
96
+ def _get_app_label(self, app_path: str) -> str:
97
+ """Convert full module path to Django app_label."""
98
+ try:
99
+ # Try to get app config by full path first
100
+ try:
101
+ app_config = apps.get_app_config(app_path)
102
+ return app_config.label
103
+ except LookupError:
104
+ pass
105
+
106
+ # Fallback: extract last part of the path as potential app_label
107
+ potential_label = app_path.split('.')[-1]
108
+ try:
109
+ app_config = apps.get_app_config(potential_label)
110
+ return app_config.label
111
+ except LookupError:
112
+ pass
113
+
114
+ return app_path
115
+
116
+ except Exception:
117
+ return app_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-cfg
3
- Version: 1.1.73
3
+ Version: 1.1.74
4
4
  Summary: 🚀 Production-ready Django configuration framework with type-safe settings, smart automation, and modern developer experience
5
5
  Project-URL: Homepage, https://github.com/markolofsen/django-cfg
6
6
  Project-URL: Documentation, https://django-cfg.readthedocs.io
@@ -552,31 +552,68 @@ def queue_document_processing(sender, instance, created, **kwargs):
552
552
 
553
553
  Django-CFG includes powerful management commands for development and operations:
554
554
 
555
+ ### 🗄️ Database & Migration Commands
556
+ | Command | Description | Example |
557
+ |---------|-------------|---------|
558
+ | **`migrator`** | Interactive database migration tool with multi-DB support | `python manage.py migrator --auto` |
559
+ | **`migrate_all`** | Simple migration command for all databases (production-ready) | `python manage.py migrate_all --dry-run` |
560
+
561
+ **Migration Command Details:**
562
+ - **`migrator`** - Full-featured migration tool with interactive menu, database status, and diagnostics
563
+ - `python manage.py migrator` - Interactive menu with all options
564
+ - `python manage.py migrator --auto` - Automatic migration of all databases
565
+ - `python manage.py migrator --database vehicles` - Migrate specific database only
566
+ - `python manage.py migrator --app vehicles_data` - Migrate specific app across all databases
567
+ - **`migrate_all`** - Simplified migration tool optimized for production and CI/CD
568
+ - `python manage.py migrate_all` - Migrate all databases automatically
569
+ - `python manage.py migrate_all --dry-run` - Show what would be migrated without executing
570
+ - `python manage.py migrate_all --skip-makemigrations` - Skip makemigrations step
571
+
572
+ ### 🔧 Configuration & Validation Commands
555
573
  | Command | Description | Example |
556
574
  |---------|-------------|---------|
557
575
  | **`check_settings`** | Validate configuration and settings | `python manage.py check_settings` |
576
+ | **`show_config`** | Display current configuration | `python manage.py show_config --format yaml` |
577
+ | **`validate_config`** | Deep validation of all settings | `python manage.py validate_config --strict` |
578
+ | **`tree`** | Display Django project structure | `python manage.py tree --depth 3 --include-docs` |
579
+
580
+ ### 🚀 API & Development Commands
581
+ | Command | Description | Example |
582
+ |---------|-------------|---------|
558
583
  | **`create_token`** | Generate API tokens and keys | `python manage.py create_token --user admin` |
559
584
  | **`generate`** | Generate API clients and documentation | `python manage.py generate --zone client` |
560
- | **`migrator`** | Smart database migrations with routing | `python manage.py migrator --apps blog,shop` |
561
- | **`script`** | Run custom scripts with Django context | `python manage.py script my_script.py` |
562
- | **`show_config`** | Display current configuration | `python manage.py show_config --format yaml` |
563
585
  | **`show_urls`** | Display all URL patterns | `python manage.py show_urls --zone client` |
586
+ | **`script`** | Run custom scripts with Django context | `python manage.py script my_script.py` |
587
+ | **`runserver_ngrok`** | Run development server with ngrok tunnel | `python manage.py runserver_ngrok --domain custom` |
588
+
589
+ ### 👤 User & Authentication Commands
590
+ | Command | Description | Example |
591
+ |---------|-------------|---------|
564
592
  | **`superuser`** | Create superuser with smart defaults | `python manage.py superuser --email admin@example.com` |
593
+
594
+ ### 📧 Communication & Integration Commands
595
+ | Command | Description | Example |
596
+ |---------|-------------|---------|
565
597
  | **`test_email`** | Test email configuration | `python manage.py test_email --to test@example.com` |
566
598
  | **`test_telegram`** | Test Telegram bot integration | `python manage.py test_telegram --chat_id 123` |
567
599
  | **`test_twilio`** | Test Twilio SMS and WhatsApp integration | `python manage.py test_twilio` |
568
600
  | **`translate_content`** | Translate JSON with LLM and smart caching | `python manage.py translate_content --target-lang es` |
601
+
602
+ ### 🎫 Built-in Module Commands
603
+ | Command | Description | Example |
604
+ |---------|-------------|---------|
569
605
  | **`support_stats`** | Display support ticket statistics | `python manage.py support_stats --format json` |
570
606
  | **`test_newsletter`** | Test newsletter sending functionality | `python manage.py test_newsletter --email test@example.com` |
571
607
  | **`newsletter_stats`** | Display newsletter campaign statistics | `python manage.py newsletter_stats --format json` |
572
608
  | **`leads_stats`** | Display lead conversion statistics | `python manage.py leads_stats --format json` |
573
- | **`runserver_ngrok`** | Run development server with ngrok tunnel | `python manage.py runserver_ngrok --domain custom` |
609
+
610
+ ### 🔄 Background Task Commands
611
+ | Command | Description | Example |
612
+ |---------|-------------|---------|
574
613
  | **`rundramatiq`** | Run Dramatiq background task workers | `python manage.py rundramatiq --processes 4` |
575
614
  | **`task_status`** | Show Dramatiq task status and queues | `python manage.py task_status --queue high` |
576
615
  | **`task_clear`** | Clear Dramatiq queues | `python manage.py task_clear --queue default` |
577
616
  | **`test_tasks`** | Test Dramatiq task processing pipeline | `python manage.py test_tasks --document-id 123` |
578
- | **`tree`** | Display Django project structure | `python manage.py tree --depth 3 --include-docs` |
579
- | **`validate_config`** | Deep validation of all settings | `python manage.py validate_config --strict` |
580
617
 
581
618
  ---
582
619
 
@@ -1,5 +1,5 @@
1
1
  django_cfg/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- django_cfg/__init__.py,sha256=uM3TJPCp4dy3Ql9MguqYKJzHp5k02lHHMjAIjDWaxr4,14288
2
+ django_cfg/__init__.py,sha256=a0pHUh44hepG9R99_4Q30VdmaKhJlmLKN_NkoCkSJTM,14288
3
3
  django_cfg/apps.py,sha256=k84brkeXJI7EgKZLEpTkM9YFZofKI4PzhFOn1cl9Msc,1656
4
4
  django_cfg/exceptions.py,sha256=RTQEoU3PfR8lqqNNv5ayd_HY2yJLs3eioqUy8VM6AG4,10378
5
5
  django_cfg/integration.py,sha256=jUO-uZXLmBXy9iugqgsl_xnYA_xoH3LZg5RxZbobVrc,4988
@@ -26,7 +26,7 @@ django_cfg/apps/accounts/admin/twilio_response.py,sha256=0K424Yn1Gle41i7xCuFs821
26
26
  django_cfg/apps/accounts/admin/user.py,sha256=h9c0wCZ4--_DLZ8rKNMPOtKECxHO8N_228TDnKLFdVA,10571
27
27
  django_cfg/apps/accounts/management/commands/test_otp.py,sha256=NPlANZtGgq9kqOHWneaTyWUIsyvpIbrP6wM0jASSfhA,6980
28
28
  django_cfg/apps/accounts/managers/__init__.py,sha256=NtY-cQl-6TUVum9HEVud4RKbR72xEiYzK14mbd9Y2Y0,50
29
- django_cfg/apps/accounts/managers/user_manager.py,sha256=TVUgPIYh82f7HNu6tl446KGm65yWA9IFrzbb0fZprw4,14852
29
+ django_cfg/apps/accounts/managers/user_manager.py,sha256=B71kdLfrcBQzFJJyX_bsKldcZKsrUauVLDodTnArJJM,14814
30
30
  django_cfg/apps/accounts/migrations/0001_initial.py,sha256=j139MrNVgq7g7bpV5B14RUhTqoYCMOa5mcaNsuHeJSY,7447
31
31
  django_cfg/apps/accounts/migrations/0002_add_phone_otp_clean.py,sha256=z7FYr6BF_CCyZSjfJqlvcUH1Jfla4JN5uqmlkNyxO4A,1490
32
32
  django_cfg/apps/accounts/migrations/0003_twilioresponse.py,sha256=KBeWBm8UJwqV5UG6KTl9Ugz3Mqe3yJ0ufzwdf8YE4Vo,3172
@@ -165,6 +165,7 @@ django_cfg/management/commands/clear_constance.py,sha256=bSUhxEIKFLmXVilQGn3s9FZ
165
165
  django_cfg/management/commands/create_token.py,sha256=beHtUTuyFZhG97F9vSkaX-u7tieAZW-C6pntujGw1C8,11796
166
166
  django_cfg/management/commands/generate.py,sha256=w0BF7IMftxNjxTxFuY8cw5pNKGW-LmTScJ8kZpxHu_8,4248
167
167
  django_cfg/management/commands/list_urls.py,sha256=D8ikInA3uE1LbQGLWmfdLnEqPg7wqrI3caQA6iTe_-0,11009
168
+ django_cfg/management/commands/migrate_all.py,sha256=zL-wf6SGIeCQ1UNyx-Kt2G1WniLvdxEMsCyYosiYaUk,4749
168
169
  django_cfg/management/commands/migrator.py,sha256=KPWbn46sGWj3y1PBq4vXjE2cY_N_UMmnNdeJaTXIJ18,19799
169
170
  django_cfg/management/commands/rundramatiq.py,sha256=62l7PvtVabtfRtrdktj_5uBbXDXi8oEde0W4IsmoHXw,8980
170
171
  django_cfg/management/commands/runserver_ngrok.py,sha256=mcTioDIzHgha6sGo5eazlJhdKr8y5-uEQIc3qG3AvCI,5237
@@ -262,8 +263,8 @@ django_cfg/templates/emails/base_email.html,sha256=TWcvYa2IHShlF_E8jf1bWZStRO0v8
262
263
  django_cfg/utils/__init__.py,sha256=64wwXJuXytvwt8Ze_erSR2HmV07nGWJ6DV5wloRBvYE,435
263
264
  django_cfg/utils/path_resolution.py,sha256=eML-6-RIGTs5TePktIQN8nxfDUEFJ3JA0AzWBcihAbs,13894
264
265
  django_cfg/utils/smart_defaults.py,sha256=-qaoiOQ1HKDOzwK2uxoNlmrOX6l8zgGlVPgqtdj3y4g,22319
265
- django_cfg-1.1.73.dist-info/METADATA,sha256=_3gdAPOfJNmlbXK9kI_pJl-97NCDqoXF8IOK8NwZ9_s,44134
266
- django_cfg-1.1.73.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
267
- django_cfg-1.1.73.dist-info/entry_points.txt,sha256=Ucmde4Z2wEzgb4AggxxZ0zaYDb9HpyE5blM3uJ0_VNg,56
268
- django_cfg-1.1.73.dist-info/licenses/LICENSE,sha256=xHuytiUkSZCRG3N11nk1X6q1_EGQtv6aL5O9cqNRhKE,1071
269
- django_cfg-1.1.73.dist-info/RECORD,,
266
+ django_cfg-1.1.74.dist-info/METADATA,sha256=xtTJrFcNOU0kFO8IUO6bwM-RcRaUKx7AoDt8jjwWsdE,45783
267
+ django_cfg-1.1.74.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
268
+ django_cfg-1.1.74.dist-info/entry_points.txt,sha256=Ucmde4Z2wEzgb4AggxxZ0zaYDb9HpyE5blM3uJ0_VNg,56
269
+ django_cfg-1.1.74.dist-info/licenses/LICENSE,sha256=xHuytiUkSZCRG3N11nk1X6q1_EGQtv6aL5O9cqNRhKE,1071
270
+ django_cfg-1.1.74.dist-info/RECORD,,