Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

django

I'm new to Django, and I can't figure out why my app isn't loading. I've created 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?

like image 600
Peter Avatar asked Apr 27 '11 22:04

Peter


3 Answers

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.

like image 104
Herman Schaaf Avatar answered Oct 14 '22 00:10

Herman Schaaf


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.

like image 20
soerface Avatar answered Oct 14 '22 01:10

soerface


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.

like image 3
Viithal Bhat Avatar answered Oct 14 '22 00:10

Viithal Bhat