I give some more simple example:

if I override save_model() (or Models.save() method) to prevent
saving:

    #in admin,py
    def save_model(self, request, obj, form, change):
        """Avoid write object"""
        print 'hello'

or
    #models.py
    def save(self, *args, **kwargs):
        print 'save()'
        return


The m2m relations are also saved.

This is a django bug? There any workaround?

On 6 ene, 13:24, Mario8k <[email protected]> wrote:
> Hi,
>
> I need to prevent to save a model overriding the ModelAdminsave_model() 
> method. When i try to avoid obj.save(), direct fields are
> not saved, but relatedm2mfields are saved as well.
>
> defsave_model(self, request, obj, form, change):
>         if request.user.is_superuser:
>             obj.save()
>         else:
>             if change:
>               #here i save another model but i never execute
> obj.save()
>
> How can I prevent to savem2mrelations too? How I can achieve the
> original object not be changed?
>
> There is an old thread with the same 
> issue:http://groups.google.com/group/django-users/browse_thread/thread/1d6c...
> Any solution?
> Thanks,
> Mario.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to