-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_template_path.py
More file actions
52 lines (41 loc) · 1.49 KB
/
test_template_path.py
File metadata and controls
52 lines (41 loc) · 1.49 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
#!/usr/bin/env python3
"""
Test template path resolution
"""
import os
import sys
from pathlib import Path
# Add Django project to Python path
project_root = Path(__file__).parent / "CarFleetManagement"
sys.path.insert(0, str(project_root))
# Set Django settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CarFleetManagement.settings')
import django
django.setup()
from django.conf import settings
from django.template.loader import get_template
def test_template_paths():
"""Test template path resolution"""
print("Testing Template Path Resolution")
print("=" * 50)
print(f"BASE_DIR: {settings.BASE_DIR}")
print(f"TEMPLATES DIRS: {settings.TEMPLATES[0]['DIRS']}")
# Check if template directories exist
for template_dir in settings.TEMPLATES[0]['DIRS']:
print(f"Template dir exists: {template_dir} -> {template_dir.exists()}")
if template_dir.exists():
print(f" Contents: {list(template_dir.iterdir())}")
# Try to load the login template
try:
template = get_template('registration/login.html')
print("✓ Successfully loaded registration/login.html")
except Exception as e:
print(f"✗ Failed to load registration/login.html: {e}")
# Check if base template exists
try:
template = get_template('base.html')
print("✓ Successfully loaded base.html")
except Exception as e:
print(f"✗ Failed to load base.html: {e}")
if __name__ == "__main__":
test_template_paths()