我想创建一个网站,帮助用户记住某些单词的含义。
class Word(models.Model):
word = models.CharField(max_length=30, unique=True)
meaning = models.CharField(max_length=200)
memory_strength = models.FloatField()
user = models.ForeignKey(User)
我希望每个用户对于Word的每个项目都具有memory_strength的单独(唯一)值,而对于每个用户,单词和含义的值将是相同的。我怎样才能做到这一点?
答案 0 :(得分:1)
class Word(models.Model):
word = models.CharField(max_length=30, unique=True)
meaning = models.CharField(max_length=200)
class Memory(models.Model):
memory_strength = models.FloatField()
user = models.ForeignKey(User)
word = models.ForeignKey(Word)