diff --git a/bikeshop_project/registration/templates/edit_member_form.html b/bikeshop_project/registration/templates/edit_member_form.html index 288e25f..a89749c 100644 --- a/bikeshop_project/registration/templates/edit_member_form.html +++ b/bikeshop_project/registration/templates/edit_member_form.html @@ -192,6 +192,7 @@ {% if not form.instance.membership %}

No membership found.

+ Add membership
{% endif %} {% endblock %} diff --git a/bikeshop_project/registration/views.py b/bikeshop_project/registration/views.py index 03e0582..3d1f983 100644 --- a/bikeshop_project/registration/views.py +++ b/bikeshop_project/registration/views.py @@ -22,6 +22,7 @@ class MemberFormView(View): context = dict(form=form) if member: + context['member'] = member return TemplateResponse(request, 'edit_member_form.html', context=context) return TemplateResponse(request, 'member_form.html', context=context) @@ -31,6 +32,7 @@ class MemberFormView(View): member = Member.objects.get(id=member_id) form = MemberForm(request.POST, instance=member) except Member.DoesNotExist: + member = None form = MemberForm(request.POST) logger.debug(form) if form.is_valid(): @@ -41,4 +43,6 @@ class MemberFormView(View): logger.debug(form) context = {'form': form} + if member: + context['member'] = member return TemplateResponse(request, 'member_form.html', context=context)