我有一个在django> = 1.8,< 1.9中无法解决的错误。 我合并了我的更改,我得到了这个:
ERRORS:
archive.Booking.articles: (fields.E304) Reverse accessor for 'Booking.articles' clashes with reverse accessor for 'Booking.articles'.
HINT: Add or change a related_name argument to the definition for 'Booking.articles' or 'Booking.articles'.
archive.Booking.articles: (fields.E305) Reverse query name for 'Booking.articles' clashes with reverse query name for 'Booking.articles'.
HINT: Add or change a related_name argument to the definition for 'Booking.articles' or 'Booking.articles'.
events.Booking.articles: (fields.E304) Reverse accessor for 'Booking.articles' clashes with reverse accessor for 'Booking.articles'.
HINT: Add or change a related_name argument to the definition for 'Booking.articles' or 'Booking.articles'.
events.Booking.articles: (fields.E305) Reverse query name for 'Booking.articles' clashes with reverse query name for 'Booking.articles'.
HINT: Add or change a related_name argument to the definition for 'Booking.articles' or 'Booking.articles'.
这是我的模特:
class Booking(events_models.AbstractBooking):
period = models.ForeignKey('archive.Period', null=True, related_name='events', help_text='ref_artistic_period')
distributions = models.ManyToManyField('archive.Distribution', related_name='bookings',
through='archive.Booking2Distribution')
def get_absolute_url(self):
return reverse('archive:detail', kwargs={'slug': self.slug, 'pk': self.id})
class Meta:
ordering = ['date_start',]
这是我的基类,包含文章字段:
class AbstractBooking(SearchMixin, TranslationMixin, MediaMixin, PriceMixin, ImagesMixin, DownloadsMixin, AdminMixin, TicketMixin):
...
articles = models.ManyToManyField('blog.Article', related_name='bookings', blank=True)
...
我尝试将articles
字段添加到我的Booking
课程中,如下所示,但没有成功:
articles = models.ManyToManyField('blog.Article', related_name='%(class)s_bookings', blank=True)