title: Updating foreign key field in Django
body: <p>I have a form that displays a drop down for a foreignkey field. The form saves the users selection, however I want the view to update the database entry rather than inserting a new one. Whats the best way to go about this?</p>
  
  <p>Current function:</p>
  
  <pre><code>def formset_valid(self, formset):
      self.object = formset.save()
      self.object.save()
      return HttpResponseRedirect(self.get_success_url())
  </code></pre>
  
  <p>I have tried something like this:</p>
  
  <pre><code>d = RevisionDefaultType.objects.get(id=1)
  n = RevisionSettings.objects.get(self.object)
  d.defaultrevisiontype = n
  d.save()
  </code></pre>
  
  <p>But it throws an error that the data being updated is not an instance.</p>