|
Posted by augustomen |
|
|
Hello all, I have a very unusual problem, because of an specific modelling.
I have created an abstract base class which looks like this: class BaseModel(models.Model):
user_added = models.ForeignKey(User, null=True, related_name='user_added')
user_modified = models.ForeignKey(User, null=True, related_name='user_modified')
class Meta:
abstract = True
Basically, my idea was that every model that descends from it gets has two tracking fields, so that I know which user added and last modified the record. However, when I descend more than one class from it, I get the following message (several times, one for each descending class): (class name): Reverse query name for field 'user_modified' clashes with related field 'User.user_modified'. Add a related_name argument to the definition for 'user_modified'. Is there a way to do what I want? Or an alternative? |
|
|
Posted by Herbert Poul ![]() |
|
|
hi,
according to the django documentaiton something like the following should work:
class BaseModel(models.Model):
user_added = models.ForeignKey(User, null=True, related_name='%(class)s_user_added')
user_modified = models.ForeignKey(User, null=True, related_name='%(class)s_user_modified')
class Meta:
abstract = True
SCT - http://sct.sphene.net |
|
|
Posted by augustomen |
|
|
Hey thanks!
It works perfectly. |



