当我运行“python manage.py runserver”时,会打印 4 次以下 2 条错误消息:
transcription.treatment: Accessor for field 'treatment_ptr' clashes with related field 'Treatment.treatment'. Add a related_name argument to the definition for 'treatment_ptr'.
transcription.treatment: Reverse query name for field 'treatment_ptr' clashes with related field 'Treatment.treatment'. Add a related_name argument to the definition for 'treatment_ptr'.
下面是我的代码。在 shared/models.py 中:
class Treatment(models.Model):
code = RandomCharField(length=6)
experiment_id = models.CharField(max_length = 10, null = True)
base_pay = models.PositiveIntegerField(default=20)
def was_started_recently(self):
expiry_time = timedelta(minutes = 5)
if datetime.now() - self.time_started < expiry_time:
return True
class OfferTreatment(Treatment):
max_offer_amount = models.PositiveIntegerField(default=50)
increment_amount = models.PositiveIntegerField(default=5)
def offer_choices(self):
return range(0, self.max_offer_amount + 1, self.increment_amount)
def is_valid_offer(amount):
return amount in self.offer_choices()
class Meta:
abstract = True
在游戏/转录/models.py 中:
class Treatment(shared.models.OfferTreatment):
short_name = 'tr'
long_name = 'Transcription'
有什么建议么?