1👍
✅
This line is critical:
collection = fields.ToManyField('maps.api.resources.CollectionResource', \
attribute='collections', full=True, null=True)
What it is saying is to look for collections
attribute in User
model and then represent each of those using CollectionResource
. In other words, you should make sure that that your User
model has collections
attribute. For that, your Collection
model has to have a foreign key with related_name
:
from django.contrib.auth.models import User
def Collection(models.Model):
...
user = models.ForeignKey(User, related_name='collections')
If you have that, Tastypie should be able to get the collections and display them in your UserResource
.
Source:stackexchange.com