Opened 9 years ago
Closed 9 years ago
#26439 closed New feature (wontfix)
ModelForm.save() should accept the "using" keyword argument
Reported by: | Andreas Poisel | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Model.save()
accepts the using
keyword argument to explicitly chose a database connection. ModelForm.save()
should offer the same functionality:
File django/forms/models.py:
def save(self, commit=True, using=None): if self.errors: raise ValueError( "The %s could not be %s because the data didn't validate." % ( self.instance._meta.object_name, 'created' if self.instance._state.adding else 'changed', ) ) if commit: # If committing, save the instance and the m2m data immediately. self.instance.save(using=using) self._save_m2m() else: # If not committing, add a method to the form to allow deferred # saving of m2m data. self.save_m2m = self._save_m2m return self.instance
Note:
See TracTickets
for help on using tickets.
A similar proposal was closed as wontfix in #8672 with the suggestion to use:
Feel free to start a thread on the DevelopersMailingList if you disagree with this decision.