Friday, March 29, 2013

How to build RESTful API for django.contrib.comments?

Hello,

I have a Generic Relationships in tastypie and incorporated the same in my resource fordjango.contrib.comments.models.Comment

My resource looks like this. It works fine for GET without the generic relationship but when I add the Generic relationship neither the GET nor POST work.


class CommentContribResource(ModelResource):  +   +     from social.api.resources import StatusUpdateResource  +     from social.models import StatusUpdate  +   +     content_object = GenericForeignKeyField({  +         StatusUpdate: StatusUpdateResource,  +         }, 'content_object')  +   +   +     class Meta:  +             queryset = Comment.objects.all()  +             resource_name = 'comments'  +             authorization= Authorization()

The error while doing GET is

error_message: "User matching query does not exist.",

While doing POST is

current transaction is aborted, commands ignored until end of transaction block

Is there a good way to build a RESTful interface with GenericForeignKeys and thedjango.contrib.comments framework?


Thanks,

Pratik


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment