#34317: wrong attribute naming in method BaseModelFormSet.save_existing
-------------------------------------+-------------------------------------
     Reporter:  Maxim Danilov        |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Forms                |                  Version:  4.1
     Severity:  Normal               |               Resolution:
     Keywords:  Formset,             |             Triage Stage:
  ModelFomset                        |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Maxim Danilov:

Old 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''"

New 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''"

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34317#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701862b4771a0-267ea0bd-6573-452b-961e-1f83ac541365-000000%40eu-central-1.amazonses.com.

Reply via email to