Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The obvious difference is that in the first case you are passing positional and keyword arguments. If you wonder what arguments <code>Model.save()</code> takes and what they do, the simplest thing is to read the source code. Then you'll find something like:</p> <pre><code>def save(self, force_insert=False, force_update=False, using=None): """ Saves the current instance. Override this in a subclass if you want to control the saving process. The 'force_insert' and 'force_update' parameters can be used to insist that the "save" must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set. """ if force_insert and force_update: raise ValueError("Cannot force both insert and updating in model saving.") self.save_base(using=using, force_insert=force_insert, force_update=force_update) </code></pre> <p>The third argument, <code>using</code>, is not documented, it specifies which db connection you want to use (if you have more than one db connection).</p> <p>To make a long story short:</p> <ul> <li>when you want to save your instance (in a view or form or whatever), you usually just want to let Django handle all this so you call <code>my_model_instance.save()</code> without arguments</li> <li><p>when you override the <code>save</code> method in your Model class, you definitly want to accept <strong>and</strong> pass the same arguments when calling on the base class <code>save</code>, ie:</p> <p>class MyModel(models.Model): def save(self, *args, **kw): do_something_here() super(MyModel, self).save(*args, **kw) do_something_else()</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload