Django ModelForm: how to override or check "save_as"

I need to add some settings for the case when the instance in Django Admin is a "saved_as" copy. Can I do this in save(), if so, how can I check save_as kwarg? Or is there a method save_as()that I can override somewhere. I could not find any information about the differences in the process between regular save()and one with save_as = True.

Can someone give me an example or give me a hint where to go?

Thanks so much for your time!

:)

+3
source share
1 answer

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.change_view

" " _saveasnew, , , _saveasnew POST.

def change_view(self, request, object_id, extra_context=None):        
    if '_saveasnew' in request.POST:
        # custom logic for save as new
        print "I am saved as new"
    return super(ModelAdmin, self).change_view(request, object_id, extra_context)
+2

All Articles