Reputation: 143
I got a "global name 'RequestContext' is not defined "error on my django project.
Please help me..
Here is my codes.
the home/views.py
import os
from django.shortcuts import render_to_response
def home(request):
return render_to_response('/home.html')
and the project urls.py
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import patterns, include, url
from django.contrib import admin
from home import views
admin.autodiscover()
urlpatterns = patterns( '',
url(r'^$', 'home.views.home', name='home'),
url(r'^admin/', include(admin.site.urls)),
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Upvotes: 0
Views: 1052
Reputation: 2324
You need to import the RequestContext from django.template
from django.template import RequestContext
return render_to_response('home.html', context_instance=RequestContext(request))
Upvotes: 3
Reputation: 2996
Just import from django.template import RequestContext
to your view.py file and change render_to_response
to
return render_to_response('/home.html', context_instance=RequestContext(request))
Upvotes: 2