擅长:python、mysql、java
<p>只有一个改变是需要的。你可以用django进出口</p>
<p><strong>模型.py</strong></p>
<pre><code> class Compositions(models.Model):
composer_key = models.ForeignKey(
Composer,
)
composition = models.CharField(
max_length=383,
unique=False
)
date_created = models.DateTimeField(default=timezone.now)
class Meta(object):
unique_together = (('composer_key','composition'),)
</code></pre>
<p>用try重写save_实例。失败时忽略错误。
<strong>管理员py</strong></p>
^{pr2}$
<p>把这个导入</p>
<pre><code>from django.db import IntegrityError
</code></pre>