Passing an argument to the save () user method

How to pass an argument to his own method of preservation, keeping the right *args, **kwargsto go to the super method? I tried something like:

form.save(my_value)

and

def save(self, my_value=None, *args, **kwargs):

   super(MyModel, self).save(*args, **kwargs)

   print my_value

But this does not seem to work. What am I doing wrong?

Edit: I found this example (see the last post, for passing 'reorder'): http://groups.google.com/group/django-users/browse_thread/thread/b285698ea3cabfc9/6ce8a4517875cb40?lnk=raot

This is essentially what I am trying to do, but my_valueis considered an unexpected argument for some reason.

+5
source share
2 answers

. :

def save(self, my_value, *args, **kwargs):
    ....

def save(self, *args, **kwargs):
    my_value = kwargs.pop('my_value', None)
+14

.

:

def save(self, my_val, *args, **kwargs):
    print my_val
    # do_something here
    return super(MyModel, self).save(*args, **kwargs)

:

MyModel.save(my_val="fooooo")

my_val .

+2

All Articles