Opened 22 months ago

Last modified 22 months ago

#34317 closed Cleanup/optimization

wrong variable naming in method BaseModelFormSet.save_existing — at Initial Version

Reported by: Maxim Danilov Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords: Formset, ModelFomset
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django.forms.models.py rows 654-667

we have a three methods:

    def save_new(self, form, commit=True):
        """Save and return a new model instance for the given form."""
        return form.save(commit=commit)

    def save_existing(self, form, instance, commit=True):
        """Save and return an existing model instance for the given form."""
        return form.save(commit=commit)

    def delete_existing(self, obj, commit=True):
        """Deletes an existing model instance."""
        if commit:
            obj.delete()

in delete_existing we have an "obj"
in save_existing we have an "instance"
why it is so? where the difference?

For ModelFormset in admin Inline we have also other instance: parent object. I can expected this "instance (parent)" instead of current "object".

My opinion attribute name "instance" in save_existing should be changed on "obj"

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top