I have a model defined like this:
class UserDetail(models.Model):
user = models.ForeignKey(User, db_index=True, unique=True, related_name='details')
favourites = models.ManyToManyField(Article, related_name='favourited_by', blank=True)
And I'm trying to do something like this:
article = get_object_or_404(Article, pk=id)
request.user.details.favourites.add(article)
Why isn't it working?
I'm getting this error:
'RelatedManager' object has no attribute 'favourites'
I guess details
isn't the right type, but why isn't it? And how can I perform a query like that?