Name error ,not defined problem

19 views
Skip to first unread message

Tara gurung

unread,
Jul 19, 2015, 6:16:52 AM7/19/15
to django...@googlegroups.com

This is my application structure with newsletter application inside SRC project.

Hellow am newbie to django framework and need some help to fix it

urls.py has this added

 urlpatterns = [

                  url
(r'^$', newsletter.views.home, name='home'),
                         url
(r'^admin/', include(admin.site.urls)),
]



settings.py

In the application i have listed the newsletter application

# Application definition


INSTALLED_APPS = (


   
'django.contrib.admin',

   
'django.contrib.auth',

   
'django.contrib.contenttypes',

   
'django.contrib.sessions',

   
'django.contrib.messages',

   
'django.contrib.staticfiles',

   
'newsletter',

)



Now in the apps part

Added the view page in views.py


from django.shortcuts import render


# Create your views here.

def home(request):

 
return render(request,"home.html",{})

In the newsletter application create a folder templates and added the home.html.


Running the server I get his error below. What might be the cause







Diego Matar

unread,
Jul 19, 2015, 11:13:20 AM7/19/15
to django...@googlegroups.com
Didi you add 'newsletter' to your INSTALLED_APPS in settings.py?

Scot Hacker

unread,
Jul 19, 2015, 11:17:11 AM7/19/15
to django...@googlegroups.com
Your URL definition is calling a module that hasn't been imported. At the top of your urls.py, add:

from newsletter import views


In the URL definition, do:

url(r'^$', views.home, name='home'),


./s

Reply all
Reply to author
Forward
0 new messages