Skip to content

Instantly share code, notes, and snippets.

@eclecticmiraclecat
Created November 6, 2020 17:14
Show Gist options
  • Save eclecticmiraclecat/7b831aeb0ea065671f06eabc251fea8a to your computer and use it in GitHub Desktop.
Save eclecticmiraclecat/7b831aeb0ea065671f06eabc251fea8a to your computer and use it in GitHub Desktop.
# urls.py
from session.views import pageCount

urlpatterns = [
    path('index/', pageCount),
]
# views.py
from django.http import HttpResponse

def pageCount(request):
  count = request.session.get('count', 0)
  count = count + 1
  request.session['count'] = count
  return HttpResponse(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment