-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
41 lines (35 loc) · 1.36 KB
/
run.py
File metadata and controls
41 lines (35 loc) · 1.36 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
#!/usr/bin/env python
"""
Django development server startup script for Midrift Hurinet NGO Accounting System
"""
import os
import sys
import django
from django.core.management import execute_from_command_line
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'midrift_accounting.settings')
# Add current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# Setup Django
django.setup()
# Run migrations first
print("Running database migrations...")
execute_from_command_line(['manage.py', 'migrate'])
# Create superuser if none exists
from django.contrib.auth import get_user_model
User = get_user_model()
if not User.objects.filter(is_superuser=True).exists():
print("Creating default superuser (admin/admin)...")
User.objects.create_superuser(
username='admin',
email='admin@midriftngdo.org',
password='admin',
first_name='System',
last_name='Administrator',
role='admin'
)
# Start development server
print("Starting Midrift Hurinet NGO Accounting System...")
print("Access the application at: http://localhost:8000")
print("Admin interface at: http://localhost:8000/admin")
execute_from_command_line(['manage.py', 'runserver', '0.0.0.0:8000'])