title: AttributeError: 'unicode' object has no attribute 'get' - In Django Forms
body: <p>I'm trying to use Django Forms with Ajax Calls.</p>
  
  <p>Previously I just used a html form that I could get all the information through request.POST['item']. But I've been thinking about validators, and I would benefit if I switched normal html forms into Django forms.</p>
  
  <p>In my HTML code (the page where the user clicks, and a AJAX calls another view with javascript):</p>
  
  <pre><code>if not request.user.is_authenticated():
      #Tells the user to login if not authenticated 
      return redirect('/webapp/login.html')
  else:
      #Get Logger 
      logger = logging.getLogger('views.logger.chartConfigure')
      logger_uuid = uuid.uuid4()
      logger_time = datetime.datetime.now()
  
      #Log the User
      logger.info("Request in editChart, User:" + str(request.user.username) + ", UUID:" + str(logger_uuid) + ", Time:" + str(logger_time))
  
      #Forms to use
      chartName = changeChartNameForm(auto_id=False)
  
      #Put Forms into a context
      context = {'chartNameForm': chartName}
  
      #Return the context
      return render(request, 'webapp/editChart.html', context)
  </code></pre>
  
  <p>The Forms that are used is a changeChartNameForm:</p>
  
  <pre><code>#Form for editing chart names
  class changeChartNameForm(forms.Form):
      #Only one variable which is called chartName, with label set to ""
      #Since I don't want any labels. I have my own in HTML.
      chartName = forms.CharField(max_length=100, label="")
      #form-control is an extra class that is required by bootstrap 3, and the html id
      #of the form is called chartName
      chartName.widget.attrs['class'] = 'form-control'
      chartName.widget.attrs['id'] = 'chartName'
  </code></pre>
  
  <p>HTML Code:</p>
  
  <pre><code>&lt;div class="input-group"&gt;
      &lt;span class="input-group-btn"&gt;
          &lt;button class="btn btn-default" type="button" id="newChartName" &gt;New Chart Name&lt;/button&gt;
      &lt;/span&gt;
      {{ chartNameForm }}
  &lt;/div&gt;
  </code></pre>
  
  <p>The Javascript code:</p>
  
  <pre><code>$.ajax(
  {
      type:"POST",
      url:"ajax_postColumnAction/",
      datatype: 'json',
      data:
      {
          'csrfmiddlewaretoken':csrftoken,
          'currentTabSelected':currentTabSelected,
          'currentColumnSelected':currentColumnSelected,
          'action':'changeName',
          'changeNameForm':$('#chartName').serialize()
      },
      success: function(response)
      {
          ...Some logic happens here
      }
  }
  </code></pre>
  
  <p>basically the javascript code will call this view, called ajax_postColumnAction:</p>
  
  <pre><code>#Get the name form, and get the newName
  changeNameForm = changeChartNameForm(request.POST['changeNameForm'])
  newName = ""
  if(changeNameForm.is_valid()):
      newName = changeNameForm.cleaned_data['chartName']
  </code></pre>
  
  <p>The return is always:</p>
  
  <p>'unicode' object does not have the attribute 'get' at the following line: if(changeNameForm.is_valid())</p>
  
  <p>I have tried the following:</p>
  
  <ol>
  <li>using data=request.POST</li>
  <li>using data=request.POST['changeNameForm']</li>
  </ol>
  
  <p>Full Traceback:</p>
  
  <pre><code>Traceback (most recent call last): 
  File "C:\Users\Desktop\Dropbox (Personal)\Django\Dashboard_Web\WebApp\views.py", line 738, in ajax_postColumnAction if(changeNameForm.is_valid()): 
  File "C:\Python27\lib\site-packages\django\forms\forms.py", line 129, in is_valid return self.is_bound and not bool(self.errors) 
  File "C:\Python27\lib\site-packages\django\forms\forms.py", line 121, in errors self.full_clean() 
  File "C:\Python27\lib\site-packages\django\forms\forms.py", line 273, in full_clean self._clean_fields() 
  File "C:\Python27\lib\site-packages\django\forms\forms.py", line 282, in _clean_fields value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name)) 
  File "C:\Python27\lib\site-packages\django\forms\widgets.py", line 207, in value_from_datadict return data.get(name, None) AttributeError: 'unicode' object has no attribute 'get'
  </code></pre>
  
  <p>Edit:</p>
  
  <p>When I Do: </p>
  
  <pre><code>print request.POST['changeNameForm']
  </code></pre>
  
  <p>I get chartName = "some text I typed in the browser"</p>