创建Django项目与应用后执行manage.py runserver遇文件未找到错误求助
Hey there, let’s get this sorted out right away. The issue here is super straightforward—you’re running the command from the wrong directory!
Why this happens
Your Django project structure should look something like this:
post_blog/ ├── manage.py # This is the file you’re missing! ├── post_blog/ (project config directory) └── blogs/ (your app directory)
You’re currently in the blogs/ folder when you run python manage.py runserver, but manage.py lives one level up in the root post_blog/ directory. That’s why Python can’t locate it.
Step-by-step fixes
Option 1: Switch to the correct directory first
In your command prompt or terminal, run this command to move up one level to the project root:cd ..Now you’re in
C:\Users\arpchauh\PycharmProjects\post_blog\, and you can run the server normally:python manage.py runserverOption 2: Run with the full path to manage.py
If you don’t want to switch directories, you can specify the complete path tomanage.pydirectly:python C:\Users\arpchauh\PycharmProjects\post_blog\manage.py runserver
Quick tip to avoid this in the future
Before running any Django management commands, always double-check that you’re in the directory containing manage.py. You can verify this by running:
dir # For Windows # OR ls # For Linux/macOS
This will list all files in your current directory—you should see manage.py listed if you’re in the right spot.
内容的提问来源于stack exchange,提问作者Arpit Chauhan

