title: Using request.session to populate a django form
body: <p>I want to save a form in session so that a user doesn't have to reapply filters when going to a different url.  Here is the error I'm getting:</p>
  
  <blockquote>
    <p>'unicode' object has no attribute 'get'</p>
  </blockquote>
  
  <p>This is the code I have:</p>
  
  <p>views.py</p>
  
  <pre><code>def someview(request):
    if request.method == 'POST':
      form = Form(request.POST, initial=request.session.get('save_form', None))
  
      if form.is_valid():
        clean_form = json.dumps(form.cleaned_data, indent=4, sort_keys=True, default=str)
        request.session['save_form'] = clean_form
  
      else:
        pass    
    else:
      form = Form()
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>class Form(forms.Form):
    startdate = forms.DateField(
        label='Start date',
        initial= '2018-01-01', 
        widget=forms.TextInput(attrs={'class':'datepicker'})
    )
    enddate = forms.DateField(
      label='End date', 
      initial= datetime.date.today() - datetime.timedelta(days=1), 
      widget=forms.TextInput(attrs={'class':'datepicker'})
    )
    manager = forms.MultipleChoiceField(
        required=False,
        choices=managers,
        widget=forms.SelectMultiple(),
    )
  </code></pre>
  
  <p>Being a beginner in Django, I'm not sure where to go from here.  I'm pretty sure the error is in the initial argument.  But, printing it, it seems print what I would expect.</p>
  
  <p>TIA</p>