#!/usr/bin/env python
"""
Django项目管理脚本
用于执行各种Django管理命令，如runserver、migrate、makemigrations等
"""
import os
import sys

if __name__ == "__main__":
    # 设置Django配置文件的默认路径
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoblog.settings")

    try:
        # 导入Django的命令行执行工具
        from django.core.management import execute_from_command_line
    except ImportError:
<<<<<<< HEAD
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.

=======
        # 如果导入失败，可能是因为Django未安装
        # 尝试导入django模块以确认是否真的未安装Django
>>>>>>> 546ebe1a60d2c3132257305a28f4957fe29a2e5a
        try:
            import django
        except ImportError:
            # Django确实未安装，抛出友好的错误提示
            raise ImportError(
                "无法导入Django。请确保已正确安装Django，"
                "并且PYTHONPATH环境变量中包含Django的路径。"
                "您是否忘记激活虚拟环境了？"
            )
        raise
<<<<<<< HEAD

=======
    # 执行命令行参数指定的Django管理命令
>>>>>>> 546ebe1a60d2c3132257305a28f4957fe29a2e5a
    execute_from_command_line(sys.argv)
