title: Stop a M2M relationship being saved in django
body: <p>I have an AdminModel that allows users to save with any of the fields left empty. However, I don't want them to be able to save when all fields are empty. I've implemented this using the following:</p>
  
  <pre><code>def save_model(self, request, obj, form, change):
      if form.has_changed():
          obj.save()
      else:
          pass
  </code></pre>
  
  <p>However, the Model has a M2M relationship with another Model, so I get the following error when I hit save:</p>
  
  <pre><code>instance needs to have a primary key value before a many-to-many relationship can be used.
  </code></pre>
  
  <p>What do I need to add to this method to stop it trying to create the M2M relationship?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I've added hacky workaround, but I'd be interested in knowing if there's a better way of doing it. The workaround was to change the <code>else</code> so it changes the ModelAdmin's field attribute so that it doesn't contain the field for the M2M relationship - this prevents it from trying to make the relationship. This is not only hacky, but also only works after it's failed to save the model once and thrown an error...</p>