From 76d3dfebc2f145dd7c277d87512c5a89b315be1d Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 15 Nov 2013 01:16:13 +0100 Subject: [PATCH] catch case where .session_key was None, leading to an invalid /detectip/None url --- nsupdate/context_processors.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nsupdate/context_processors.py b/nsupdate/context_processors.py index 49caf60..c7adf37 100644 --- a/nsupdate/context_processors.py +++ b/nsupdate/context_processors.py @@ -54,4 +54,9 @@ def update_ips(request): # kill the IP, it is not up-to-date any more # note: it is used to fill form fields, so set it to empty string put_ip_into_session(s, '', kind=key) + if s.session_key is None: + # if we have a new session (== not loaded from database / storage), we + # MUST save it here to create its session_key as the base.html template + # uses .session_key to build the URL for detectip: + s.save() return {}