Could not import 'collection.views.index'. View does not exist in module collection.views


#1

I am on my way to add the ‘edit’ part which will allow me change my thing without going to the admin page.

i found this error after finishing all the code.

what i am supposed to do ?!


#2

Looks like you might be using the old HWA — which version of Django are you using and what does your urls.py look like?


#3

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

urlpatterns = patterns('',
        url(r'^$', 'collection.views.index', name='home'),
        url(r'^about/$',TemplateView.as_view(template_name='about.html'),name='about'),
        url(r'^contact/$',TemplateView.as_view(template_name='contact.html'),name='contact'), 
        url(r'^things/(?P<slug>[-\w]+)/$','collection.views.thing_detail',name='thing_detail'),
        url(r'^things/(?P<slug>[-\w]+)/edit/$','collection.views.edit_thing',name='edit_thing'),
        url(r'^admin/', include(admin.site.urls)),
)  

Iam using django 1.9.6

And this is the error screenshot.


#4

Looks like you’re using an old version of Hello Web App, try updating your urls.py using the guide here: https://hellowebapp.com/migrate/


#5
from django.conf.urls import url, patterns, include
from django.contrib import admin
from django.views.generic import TemplateView
from collection import *


#from collection.views import index,thing_detail,edit_thing

urlpatterns = [
        url(r'^$', 'views.index', name='home'),
        url(r'^about/$',TemplateView.as_view(template_name='about.html'),name='about'),
        url(r'^contact/$',TemplateView.as_view(template_name='contact.html'),name='contact'),
        url(r'^things/(?P<slug>[-\w]+)/$','views.thing_detail',name='thing_detail'),
        url(r'^things/(?P<slug>[-\w]+)/edit/$','views.edit_thing',name='edit_thing'),
        url(r'^admin/', include(admin.site.urls)),
]

This is my new urls.py file and there is another error which i could not handle !


#6

You have quotes (’) around views.index. :)