I have a lot of models with voting functionality, so I created a structure like this:
class Voteable(models.Model):
likes_balance = models.IntegerField(default=0, editable=False)
votes = models.ManyToManyField(User, blank=True, editable=False)
likes = models.ManyToManyField(User, blank=True, editable=False)
class Meta:
abstract = True
class Item(Voteable):
title = models.CharField(max_length=20, db_index=True)
description = models.TextField(max_length=1000)
contact_user = models.ForeignKey(User, null=True, blank=True)
class Meta:
abstract = True
class Movie(Item):
cover = models.ImageField(upload_to='images/covers/')
class Car(Item):
seller = models.CharField(max_length=50)
When I try to create tables with "python manage.py syncdb" I get error message:
Accessor for m2m field 'likes' clashes with related field 'User.movie_set'. Add a related_name argument to the definition for 'likes'.
Of cause I have much more fields in Item class, so don't want to copy all of them to all subclasses and just set related_name like suggested in error.
Any suggestions how to deal with it?