我需要定義一個包含組織者和參與者數量的會議模型。所有參與者都來自標準的用戶身份驗證模塊。Django中的OneToMany和OneToOne關係衝突
from django.db import models
from django.contrib.auth.models import User
class Meeting(models.Model):
organizer=models.ForeignKey(User)
participants=models.ManyToManyField(User)
但是,在運行時執行syncdb時,我得到了以下錯誤
Error: One or more models did not validate: hub.meeting: Accessor for field 'organizer' clashes with related m2m field 'User.meeting_set'. Add a related_name argument to the definition for 'organizer'. hub.meeting: Accessor for m2m field 'participants' clashes with related field 'User.meeting_set'. Add a related_name argument to the definition for 'participants'.
誰能幫我解決這個問題?
這個問題的題目並沒有什麼關係的問題:我建議改變它 –