NameError at / name 'editareapage' is not defined
Question: Ok so i am a noob building a basic site in django with python. I am trying to
implement a new page in my site called edit area. Whenever i visit the page
all i get is this...

    
    
    NameError at /
    name 'editareapage' is not defined
    Request Method: GET
    Request URL:    http://127.0.0.1:8000/
    Django Version: 1.4.1
    Exception Type: NameError
    Exception Value:    
    name 'editareapage' is not defined
    

My views.py

    
    
    from django.http import HttpResponse
    from django.shortcuts import render_to_response
    import datetime
    def hello(request):
        return HttpResponse("Hello, World!")
    
    def mainpage(request):
    
        return render_to_response('mainpage.html')
    
    def current_datetime(request):
        now = datetime.datetime.now()
        return render_to_response('current_datetime.html', {'current_time':now})
    
    def hours_ahead(request,offset):
        try:
            offset= int(offset)
        except ValueError:
            raise Http404()
    
        dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
        html = "<html><body>In %s hour(s), it will be %s.</body></html>" % (offset,dt)
        return HttpResponse(html)
    
    def editareapage(request):
        return render_to_response('editareapage.html')
    

Also it is worth noting that editareapage is the one i am trying to access.

Here is my urls.py

    
    
        from django.conf.urls import patterns, include, url
    from MyProj.views import hello,mainpage, current_datetime, hours_ahead
    # Uncomment the next two lines to enable the admin:
    from django.contrib import admin
    admin.autodiscover()
    
    urlpatterns = patterns('',
          (r'^hello/$', hello),
          (r'^$', mainpage),
          (r'^time/$',current_datetime),
          (r'^time/plus/(\d{1,2})/$', hours_ahead),
          (r'^editareapage/$', editareapage),
        # Examples:
        # url(r'^$', 'MyProj.views.home', name='home'),
        # url(r'^MyProj/', include('MyProj.foo.urls')),
    
        # Uncomment the admin/doc line below to enable admin documentation:
        # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    
        # Uncomment the next line to enable the admin:
         (r'^admin/', include(admin.site.urls)),
    )
    

Hopefully this is enough for somone to help me, thanks!


Answer: You should import editareapage in `urls.py`

    
    
    from MyProj.views import hello, mainpage, current_datetime, hours_ahead, editareapage
    

