From 94739d35084bcb0119dfbe59b344041e5462126a Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Thu, 26 Jan 2017 18:52:27 +0100 Subject: [PATCH] Set ref in form if user already has one --- contest/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contest/views.py b/contest/views.py index 6612f65..ae4aae0 100644 --- a/contest/views.py +++ b/contest/views.py @@ -148,7 +148,10 @@ def updateRef(request, shadow, uid): messages.success(request, "%s%s ref set to %s" % ("(shadow) " if shadow else "", user, ref)) return HttpResponseRedirect(reverse("contest:registerRefs")) else: - form = UpdateRefForm() + data = {} + if user.ref: + data["existingRef"] = user.ref + form = UpdateRefForm(initial=data) return render(request, 'contest/updateRef.html', {'userobj': user, 'form': form, "shadow": shadow})