I want to set a cookie inside a view and then have that view render a template. As I understand it, this is the way to set a cookie:
def index(request):
This is how to do it:
from django.shortcuts import render def home(request, template): response = render(request, template) # django.http.HttpResponse response.set_cookie(key='id', value=1) return response