Thanks DR

Mike

On 16/08/2011 6:10pm, Daniel Roseman wrote:
On Tuesday, 16 August 2011 08:21:24 UTC+1, Mike Dewhirst wrote:

    When using save() in a model, what is the difference between ...

    save(self, force_insert=False, force_update=False) or
    save(self, force_insert=False, force_update=False, **kwargs)
         # whatever
         super(Xyz, self).save(force_insert, force_update) or
         super(Xyz, self).save(force_insert, force_update, **kwargs)

    and

    save(self, *arg, **kwargs)
         # whatever
         super(Xyz, self).save(*args, **kwargs)

    I see the former in a fair bit of django example code around the
    place
    and the latter in the docs here

    
https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
    
<https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods>

    Thanks for any insights

    Mike


There's no practical difference right now. The main reason for the (*args, **kwargs) format is for forwards compatibility: if Django introduces a new argument to `save` in future versions, your code might stop working if you've hard-coded the function to only pass two parameters.
--
DR.
--
You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/zk3ttVQDbSgJ.
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.

--
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