title: Any danger in manually setting cleaned_data in Django?
body: <p>This may be a dumb question, but I'm a bit unsure if it's safe to manually set the cleaned_data. The docs <a href="https://docs.djangoproject.com/en/dev/topics/forms/" rel="nofollow noreferrer">says</a>:</p>
  <blockquote>
  <p>Once is_valid() returns True, you can process the form submission
  safe in the knowledge that it conforms to the validation rules defined
  by your form. While you could access request.POST directly at this
  point, it is better to access form.cleaned_data. This data has not
  only been validated but will also be converted in to the relevant
  Python types for you.</p>
  </blockquote>
  <p>For more context, say we have a modelform which has several fields such as a book's title, book's author, and a field which asks for a url.</p>
  <p>The form conditions are: if the url field is empty, the user must provide the title and author. If the url field is given and nothing else, I would parse the html from the given url and extract the title and author automatically for the user.</p>
  <p>In the case where I automatically grab the title and author from the url, what would be the best way to handle saving this data to the model, since the form would return an empty cleaned_data for author and title? I made sure the data parsed will conform to the validate rules I have in the model, but setting cleaned_data like this seems suspicious.</p>
  <p>In modelform class:</p>
  <pre><code>def save(self, commit = True, *args, **kwargs):
      parsed_title = ... # String returned by my html parsing function
      parsed_author = ... # String returned by my html parsing function
      self.cleaned_data['title'] = parsed_title
      self.cleaned_data['author'] = parsed_author
  </code></pre>
  <br/>
  <br/>
  <p><strong>EDIT:</strong></p>
  <p>Thanks, I made it like so:</p>
  <pre><code>def save(self, commit=True, *args, **kwargs):
       instance = super(BookInfoForm, self).save(commit=commit, *args, **kwargs)
       ....
       instance.title = parsed_title
       instance.author = parsed_author
  
       return instance
  </code></pre>
  <p>This is a bit off topic since you've already answered the original question, but the above code breaks some other part. Instead of saving the compiled info to  <code>http://..../media/books/&lt;id&gt;</code> where <code>&lt;id&gt;</code> is the book id, it saves it to <code>http://..../media/books/None</code>.</p>
  <p>I have a add/edit function in my <code>views.py</code> that handles adding and editing:</p>
  <pre><code>def insert_or_modify(request, id=None):
      if id is not None:
           book = BookModel.objects.get(pk=id)
      else:
           book = BookModel()
  
     if request.method == 'POST':
         form = BookInfoForm(request.POST, instance=book)
         if form.is_valid():
             form.save()
  
     ....
     
     return render_to_response(...)
  </code></pre>
  <p>Is there a way to make sure the id is present so that I won't get id=None? I guess more specifically, in the save() in the modelform, is there a way to create a new instance with an id if instance.id = None? Although I thought calling super(ModelForm, self).save(...) would do that for me?</p>
  <p>Thanks again!</p>