I believe that you should also override `save` method with your
commit=False.

That `save` method and `save_existing_objects` method works in sync. It is
supposed that they should have the same `commit` value.

Hope that helps,

On Wed, Aug 10, 2016 at 10:14 AM, Vincenzo <[email protected]> wrote:

> The Django version I'm using is the 1.9.4
>
> Il giorno martedì 9 agosto 2016 22:04:57 UTC+2, Constantine Covtushenko ha
> scritto:
>>
>> Hi Vincenzo,
>>
>> Can you please specify Django version that you are using.
>>
>> Regards,
>>
>> On Tue, Aug 9, 2016 at 6:06 PM, Vincenzo <[email protected]> wrote:
>>
>>> Hi there,
>>> I'm using the admin and I have a form admin  and an inline admin form.
>>> For this inline admin, I need to ignore modifications done for existing
>>> items: for this task I have done an override of save_existing_objects
>>> method for a Formset which inherit from forms.models.BaseInlineFormset.
>>> In this function I simply call the super with commit=False but doing that
>>> cause the following error:
>>>
>>> traceback (most recent call last):
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/core/handlers/base.py", line 149, in get_response
>>>     response = self.process_exception_by_middleware(e, request)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/core/handlers/base.py", line 147, in get_response
>>>     response = wrapped_callback(request, *callback_args, **
>>> callback_kwargs)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/contrib/admin/options.py", line 541, in wrapper
>>>     return self.admin_site.admin_view(view)(*args, **kwargs)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/utils/decorators.py", line 149, in _wrapped_view
>>>     response = view_func(request, *args, **kwargs)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/views/decorators/cache.py", line 57, in
>>> _wrapped_view_func
>>>     response = view_func(request, *args, **kwargs)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/contrib/admin/sites.py", line 244, in inner
>>>     return view(request, *args, **kwargs)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/reversion/admin.py", line 186, in change_view
>>>     return super(VersionAdmin, self).change_view(request, object_id,
>>> form_url, extra_context)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/contrib/admin/options.py", line 1440, in change_view
>>>     return self.changeform_view(request, object_id, form_url,
>>> extra_context)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/utils/decorators.py", line 67, in _wrapper
>>>     return bound_func(*args, **kwargs)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/utils/decorators.py", line 149, in _wrapped_view
>>>     response = view_func(request, *args, **kwargs)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/utils/decorators.py", line 63, in bound_func
>>>     return func.__get__(self, type(self))(*args2, **kwargs2)
>>>   File "/usr/lib/python3.4/contextlib.py", line 30, in inner
>>>     return func(*args, **kwds)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/contrib/admin/options.py", line 1379, in changeform_view
>>>     self.save_related(request, form, formsets, not add)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/contrib/admin/options.py", line 1015, in save_related
>>>     self.save_formset(request, form, formset, change=change)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/contrib/admin/options.py", line 1003, in save_formset
>>>     formset.save()
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/forms/models.py", line 645, in save
>>>     return self.save_existing_objects(commit) + self.save_new_objects(
>>> commit)
>>>   File "/home/vincenzo/workspace/mynetgest2/warehouse/forms.py", line
>>> 118, in save_existing_objects
>>>     instances_not_saved = super(IncomingBillOfLadingRowFormset, self).
>>> save_existing_objects(commit=False)
>>>   File "/opt/virtualenv/Environments/mynetgest2/lib/python3.4/site-
>>> packages/django/forms/models.py", line 763, in save_existing_objects
>>>     self.saved_forms.append(form)
>>> AttributeError: 'IncomingBillOfLadingRowFormFormSet' object has no
>>> attribute 'saved_forms'
>>>
>>> Is there something I'm doing wrong?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/cc82fa71-3edb-49f7-b46b-c1f043eafd2a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/cc82fa71-3edb-49f7-b46b-c1f043eafd2a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/38a93a33-7681-4385-970b-3714af473a03%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/38a93a33-7681-4385-970b-3714af473a03%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boWJiPqXS%3DeAJBOL-mAP%2BfAinn9G02rDw2v6XU6VvvHHfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to