擅长:python、mysql、java
<p>根据<a href="https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods" rel="nofollow">"Overriding predefined model methods"</a>段:</p>
<blockquote>
<p>It’s also important that you pass through the arguments that can be
passed to the model method – that’s what the *args, **kwargs bit does.
Django will, from time to time, extend the capabilities of built-in
model methods, adding new arguments. If you use *args, **kwargs in
your method definitions, you are guaranteed that your code will
automatically support those arguments when they are added.</p>
</blockquote>
<p>换句话说,您需要传递<code>*args</code>和{<cd2>}:</p>
<pre><code>def save(self, *args, **kwargs):
if not self.id:
self.raw_name = self.name.replace(" ", "_")
super(Mall, self).save(*args, **kwargs)
</code></pre>