Geoff
Geoff

Reputation: 6629

Python django cannot import name views

Ive setup django and am setting up my urls like

from django.conf.urls import include, url
from django.contrib import admin
 from . import views

urlpatterns = [
   url(r'^admin/', include(admin.site.urls)),
   url(r'^home/$', views.homepage),
]

The above always produces an error

cannot import name views

PROJECT STRUCTURE

geoff
   settings.py
   urls.py  //using this
   wsgi.py

 homepage
   migrations->folder
   _init_.py
   .....others here
   views.py

Upvotes: 1

Views: 1796

Answers (3)

sachin
sachin

Reputation: 379

You have a indent issue in your urls.py.

Check the below line

`from . import views`

You have a extra space at start of this line. Please remove the space your problem will gets solved.

Upvotes: 0

sos418
sos418

Reputation: 852

You need to change from . import views to from homepage.views import homepage(mapping function)

Upvotes: 0

sp________
sp________

Reputation: 2645

Try:

from homepage import views

Upvotes: 3

Related Questions