Reputation: 46380
So Tastypie automatically generates the fields based on the fields of your Django Model (if you use ModelResource). I would like to use some methods from my Model as fields in the Resource. Is there a good way to do this in Tastypie? I know it's possible to do it using hydrate
but that seems a bit hackish.
Upvotes: 0
Views: 122
Reputation: 1339
Try this:
class UserCharField(ModelResource):
stuff = fields.CharField(attribute='get_stuff_method', readonly=True)
class Meta:
queryset = User.objects.all()
Upvotes: 1