title: Django Modelform altering User Input before validation
body: <p>iam a beginner with Django and i am having a problem which i am not able to solve so far even that i have some understanding what is not going on.</p>
  <p>I have a model with an HStore Field</p>
  <p>models.py</p>
  <h1>--------</h1>
  <pre><code>class myModel(models.Model):
  
       myVariable = HStoreField()
  </code></pre>
  <p>forms.py</p>
  <h1>--------</h1>
  <pre><code>class myModel(forms.ModelForm):
  
  class Meta:
          model = myModel
          fields = (
                    'myVariable',
                    )
  </code></pre>
  <p>here is what i am trying to achieve.
  I want the user to enter a comma seperated list ob strings in example the user input to the HStore field might be</p>
  <p>&quot;&quot;&quot;String1, String2, String3, String4 &quot;&quot;&quot; (without the quotas)</p>
  <p>what iam trying to do is to convert this &quot;list/string&quot; into a JSON conform format as a dictionary, considering the above case it should look like this</p>
  <p>{ &quot;String1&quot;: &quot;&quot;, &quot;String2&quot;: &quot;&quot;, &quot;String3&quot;: &quot;&quot;, &quot;String4&quot;: &quot;&quot; }</p>
  <p>i wrote a function for this. The function logic should work and i know that it dont work because if the is_valid() function is called within the view the clean() function starts after the validation, anyway here is the function.</p>
  <p>forms.py on top of the &quot;class meta:&quot;</p>
  <pre><code>def clean(self):
  
      cleaned_data = self.cleaned_data
      str_inputTags = cleaned_data.get('act_tags_Hstore')
    
      if str_inputTags:
           
          # Splitting the input String into a list of tags
          list_tags = str_inputTags.split(&quot;,&quot;)
           
          # Construct JSON Dict string out of the list of tags
          for tag in list_tags:
              str_inputJSON = &quot;\&quot;%s\&quot;: \&quot;\&quot;, &quot; % (tag)
   
          # Remove the last added comma and space from the string
          str_inputJSON = str_inputJSON[:-2]
          # Add { in front and } to the back of the entered string       
          str_inputJSON = &quot;{&quot; + str_inputJSON + &quot;}&quot;
               
          # Setting the cleaned_data to the newly constructed string
          cleaned_data['act_tags_Hstore'] = str_inputJSON
           
          return cleaned_data 
  </code></pre>
  <p>Here is the Error i get within the form</p>
  <blockquote>
  <p>Could not load JSON data.</p>
  </blockquote>
  <p>So far i believe what i am trying to do won't work within the clean method and neither within the clean_field1 method i probably have to do the above operation before the to_python method is called. Because right now the field is validated before my method/clean is called.
  But i dont understand how to do this at the moment.</p>