1๐
โ
Add context_instance=RequestContext(request) to every view that you will use a form inside it:
It seems you are not passing the context processor
from wiki.models import Page
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
def view_page(request,page_name):
try:
page = Page.objects.get(pk=page_name)
except Page.DoesNotExist:
return render_to_response("create.html",{"page_name":page_name})
content = page.content
return render_to_response("view.html",{"page_name":page_name , "content":content}, context_instance=RequestContext(request))
def edit_page(request,page_name):
try:
page = Page.objects.get(pk=page_name)
content = page.content
except Page.DoesNotExist:
content = ""
return render_to_response("edit.html",{"page_name":page_name, "content":content}, context_instance=RequestContext(request))
def save_page(request , page_name):
content = request.POST.get('content', 'this is the default')
try:
page = Page.objects.get(pk = page_name)
page.content = content
except Page.DoesNotExist:
page = Page(name= page_name , content=content)
page.save()
return HttpResponseRedirect("/wikicamp/" + page_name + "/")
Give a try to this .
Still you are getting the problem please post the urls .py also
๐คmasterofdestiny
2๐
from django.template import RequestContext
return render_to_response('contact_form.html',
{'errors': errors}, context_instance=RequestContext(request))
and also use the csrf_token tag inside the element if the form is for an internal URL, e.g.:
"form action="" method="post">{% csrf_token %}"
๐คrahul
- [Django]-Django: Direct assignment to the forward side of a many-to-many set is prohibited. Use user.set() instead
- [Django]-Deleting the tags that are not used by any other object
- [Django]-How include a filefield in a django admin model form that is not in the model
- [Django]-How do you access/configure summaries/snippets in Django Haystack
- [Django]-Multiple Django Celery Tasks are trying to save to the same object and failing
Source:stackexchange.com