Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
"""
Django Admin Utility Script
---------------------------
This script allows you to run administrative tasks for the Student_Management project.

Pull Request Enhancements:
- Added better error handling
- Added optional logging
- Included environment variable validation
"""

import os
import sys
import logging

# Set up logging (Optional debug output)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def main():
"""Run administrative tasks."""
"""Run Django administrative tasks."""
# Set default settings module if not already set
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Student_Management.settings')

# Validate environment setup
if 'DJANGO_SETTINGS_MODULE' not in os.environ:
logger.error("DJANGO_SETTINGS_MODULE is not set.")
sys.exit(1)

try:
from django.core.management import execute_from_command_line
except ImportError as exc:
logger.exception("Django import failed.")
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc

logger.info("Starting Django administrative command...")
execute_from_command_line(sys.argv)


Expand Down