fix manyToMany error when creating deployment
authorScott Baker <smbaker@gmail.com>
Tue, 7 Oct 2014 00:17:40 +0000 (17:17 -0700)
committerScott Baker <smbaker@gmail.com>
Tue, 7 Oct 2014 00:17:40 +0000 (17:17 -0700)
planetstack/core/admin.py

index 11a2c59..a77be5b 100644 (file)
@@ -527,10 +527,10 @@ class DeploymentAdminForm(forms.ModelForm):
     def save(self, commit=True):
       deployment = super(DeploymentAdminForm, self).save(commit=False)
 
-      deployment.flavors = self.cleaned_data['flavors']
-
       if commit:
         deployment.save()
+        # this has to be done after save() if/when a deployment is first created
+        deployment.flavors = self.cleaned_data['flavors']
 
       if deployment.pk:
         # save_m2m() doesn't seem to work with 'through' relations. So we