Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
96 lines (78 loc) · 2.69 KB
/
Copy pathsetup.py
File metadata and controls
96 lines (78 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# diagnosis.py - Run this to check your Django configuration
import os
import sys
import django
from django.conf import settings
from django.apps import apps
# Add your project root to Python path
sys.path.append(".")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CareBridge.settings")
django.setup()
def diagnose_apps():
"""Diagnose Django apps and model configuration."""
print("=== DJANGO APPS DIAGNOSIS ===\n")
# Check installed apps
print("1. INSTALLED_APPS:")
for i, app in enumerate(settings.INSTALLED_APPS, 1):
print(f" {i}. {app}")
print()
# Check loaded apps
print("2. LOADED APPS:")
for app_config in apps.get_app_configs():
print(f" - {app_config.name} ({app_config.verbose_name})")
# Check models in each app
models = app_config.get_models()
if models:
print(f" Models: {', '.join([model.__name__ for model in models])}")
else:
print(" No models found")
print()
# Check for model conflicts
print("3. MODEL REGISTRY:")
all_models = apps.get_models()
model_names = {}
for model in all_models:
model_name = model.__name__
app_label = model._meta.app_label
if model_name in model_names:
print(
f" ⚠️ CONFLICT: {model_name} found in both {model_names[model_name]} and {app_label}"
)
else:
model_names[model_name] = app_label
print(f" ✅ {app_label}.{model_name}")
print("\n=== DIAGNOSIS COMPLETE ===")
# Check for common issues
issues = []
# Check if old models.py exists
if os.path.exists("app/models.py"):
issues.append(
"❌ Old app/models.py file still exists - this may cause conflicts"
)
# Check for empty __init__.py files
required_init_files = [
"app/__init__.py",
"app/account/__init__.py",
"app/appointment/__init__.py",
"app/medical_record/__init__.py",
"app/notification/__init__.py",
"app/core/__init__.py",
]
for init_file in required_init_files:
if not os.path.exists(init_file):
issues.append(f"❌ Missing {init_file}")
if issues:
print("\n🔧 ISSUES TO FIX:")
for issue in issues:
print(f" {issue}")
else:
print("\n✅ No configuration issues found!")
if __name__ == "__main__":
try:
diagnose_apps()
except Exception as e:
print(f"❌ Error running diagnosis: {e}")
print("\nThis usually means there's a configuration issue.")
print(
"Check your DJANGO_SETTINGS_MODULE and ensure all apps are properly configured."
)