Peter
Peter

Reputation: 273

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

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?

Upvotes: 7

Views: 18795

Answers (3)

Viithal Bhat
Viithal Bhat

Reputation: 41

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.

Upvotes: 4

soerface
soerface

Reputation: 6813

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.

Upvotes: 9

Herman Schaaf
Herman Schaaf

Reputation: 48425

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.

Upvotes: 9

Related Questions