0👍
✅
Do this:
#settings.py
TEMPLATE_CONTEXT_PROCESSORS = (
...,
'django.core.context_processors.csrf',)
In your view, use csrf decorator instead of manually adding it.
from django.views.decorators.csrf import csrf_protect
from django.template import RequestContext
@csrf_protect
def showWeekEnd(request):
c = RequestContext(request)
return render_to_response('EN/current_datetime.html', c)
1👍
Did you try to add RequestContext(request) in your render_to_response ?
views.py
from django.template import RequestContext
return render_to_response('EN/current_datetime.html', c, RequestContext(request))
1👍
from django.shortcuts import render
import datetime
def showWeekEnd(request):
if request.method == 'POST':
return render(request, 'EN/current_datetime.html')
def showTime(request):
c = {}
c["day_list"] = ['wednesday','thursday','friday']
c["current_date"] = datetime.datetime.now()
return render(request, 'FR/current_datetime.html', c)
- [Answered ]-Convert Queryset to dictionary with values for JSON
- [Answered ]-Doing some processing locally before uploading
- [Answered ]-Django Abstract BaseUser
- [Answered ]-Django to DjangoRestFramework – Where do I do form validation (I am no longer using forms.py – I'm using serializers.py)
Source:stackexchange.com