This form should not post, it’s grabbing what is currently saved from the previous setup page. However, during this point in my setup: I’m just trying to get the session information and save it. In case a user decides to change their information.
What I’ve tried thus far:
request.session['form_data'] = user_info_form.cleaned_datawill only work ifform.is_valid()holds.request.session.get['single_input_variable_name']will not work with lists, dictionaries, or tuples.
What is my next move?
if request.method == 'POST':
...
else:
profile = Profile.objects.get(user=request.user)
initial = {}
initial['first_name'] = request.user.first_name
initial['last_name'] = request.user.last_name
initial['email'] = request.user.email
if profile:
initial['about'] = profile.about
initial['country'] = profile.country
user_info_form = UserInfoForm(initial=initial)
context['user_info_form'] = user_info_form
context['profile'] = profile
Thanks for your help in advance.
Almost there; try
This will be populated regardless of whether the form is valid or not. You can then put it back into a form on a subsequent request: