开发者

Django App not working: "Error: No module named app_name"

开发者 https://www.devze.com 2023-03-01 08:17 出处:网络
I\'m new to Django, and I can\'t figure out why my app isn\'t loading. I\'ve create开发者_JS百科d all the files: models.py, views.py, urs.py with default code in. But when I run python manage.py runse

I'm new to Django, and I can't figure out why my app isn't loading. I've create开发者_JS百科d all the files: models.py, views.py, urs.py with default code in. But when I run python manage.py runserver, it says the following:

Error: No module named app_name

What am I doing wrong?


Did you remember to include __init__.py in your folder?

If you did, make sure the permissions on the file are also correct. There's also a similar question here.


Just an additional hint: Instead of manually creating the files you can use django-admin.py startapp APPNAME to automatically create a directory with all necessary files for a new app.


I got your point the init file thing also dosen't work out for me as well. Just ensure that are you writing the proper command inside the proper directory while creating the app, using the terminal.

Like while writing the command "django-admin startapp APP_NAME", ensure that the command is written inside your root configuration directory (which gets created after you typein command "django-admin startproject PROJECT-NAME"), not anywhere else. Then mention the app name inside the settings.py file, under the INSTALLED_APPS[ ] list. Then finally run the command "python manage.py runserver" in the same root configuration directory. I assure you, this will work for sure and the "No modules found" thing will disappear. Have a try and tell me if it don't. Thank you.

0

精彩评论

暂无评论...
验证码 换一张
取 消