Tjs
Tjs

Reputation: 64

Why does Django say there is no module named views?

I have a Django project that I wrote. I am testing it on the development server. It is saying that there is no module named views, even though the file views.py is one level higher than it in the directory views. Why is this? Does the views.py need to be in the same folder as the urls.py? Is that causing this?

Upvotes: 1

Views: 177

Answers (2)

Aswin Murugesh
Aswin Murugesh

Reputation: 11080

The views.py must be in the same folder as in the urls.py. If not, while importing the views.py, its better to specify the exact path of the views.py, from the SYS_PATH of the project (from the folder where you have the manage.py file), which will help

Upvotes: 1

theharshest
theharshest

Reputation: 7867

Yes they should be in the same folder. You can check the directory structure here - https://docs.djangoproject.com/en/dev/intro/tutorial03/

Upvotes: 2

Related Questions