#!/usr/bin/env python
"""
Django's command-line utility for administrative tasks.

This script serves as the entry point for all Django management commands
including database migrations, server startup, and custom commands.
"""
import os
import sys


def main():
    """
    Main entry point for Django management commands.
    
    Sets the default Django settings module and executes management commands
    from the command line. This function ensures proper Django setup and
    provides error handling for common configuration issues.
    """
    # Set the default settings module for the Django project
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
    
    try:
        # Import Django's management execution utilities
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        # Provide helpful error message if Django is not installed
        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
    
    # Execute the management command with command line arguments
    execute_from_command_line(sys.argv)


# Execute main function when script is run directly
if __name__ == '__main__':
    main()
