Hi All,
I have been scratching around this for a bit now.
Sometimes I don't want people to have to register on my site, but I do want to capture some information about them and reuse it across multiple mini questionnaires/forms.
I can happily set and get a session variable using the session 'dictionary'
What I am trying to figure out is how to then use this information to populate fields so I can know who is giving which answers.
I could take the session variable and write this to the template, grab this information in the template and write it to the input using jquery. This doesn't seem the most efficient way.
I assume writing this information in the view would be optional, alternatively is there a way to foreignkey type of approach.
Also I am pretty new to django so i might be way off the mark..
many thanks in advance,
Aaron
my view:
def sessionStoreView(request):
if request.method == "POST":
form = sessionStoreForm(request.POST)
if form.is_valid():
model_instance = form.save(commit=False)
model_instance['participant'] = request.session.get('participant') #something like that would be great if it worked
model_instance.save()
return HttpResponseRedirect('sessionStore')
else:
form = sessionStoreForm()
return render(request, "sessionStore.html", {'form': form})