class PostResource(ModelResource): label = fields.ToManyField(LabelResource, 'label', null=True) class Meta: queryset = Post.objects.all() resource_name = 'post' authorization = Authorization()
class ArticleResource(ModelResource): authors = fields.ToManyField(AuthorProfileResource, 'authors', related_name='articles', full=True) class Meta: queryset = Article.objects.all() authentication = BasicAuthentication() authorization = PerUserAuthorization()
class TaggableResource(ModelResource): taggabletags = fields.ToManyField( 'related_resource.api.resources.TaggableTagResource', 'taggabletags', null=True) class Meta: resource_name = 'taggable' queryset = Taggable.objects.all() authorization = Authorization()
class FreshNoteResource(ModelResource): media_bits = fields.ToManyField( 'related_resource.api.resources.FreshMediaBitResource', 'media_bits', related_name='note') class Meta: queryset = Note.objects.all() resource_name = 'freshnote' authorization = Authorization()
class AuthorProfileResource(ModelResource): user = fields.ToOneField(UserResource, 'user', full=True) sites = fields.ToManyField(SiteResource, 'sites', related_name='author_profiles', full=True) class Meta: queryset = AuthorProfile.objects.all() authentication = BasicAuthentication() authorization = Authorization()
class ContactResource(ModelResource): groups = fields.ToManyField(ContactGroupResource, 'groups', related_name='members', null=True, blank=True) class Meta: queryset = Contact.objects.prefetch_related('groups') resource_name = 'contact' authorization = Authorization()
class OrderResource(ModelResource): items = fields.ToManyField( "related_resource.api.resources.OrderItemResource", "items", related_name="order", full=True) class Meta: queryset = Order.objects.all() resource_name = 'order' authorization = Authorization()
class ContactGroupResource(ModelResource): members = fields.ToManyField( 'related_resource.api.resources.ContactResource', 'members', related_name='groups', null=True, blank=True) class Meta: queryset = ContactGroup.objects.prefetch_related('members') resource_name = 'contactgroup' authorization = Authorization()
class DogResource(ModelResource): owner = fields.ToOneField(PersonResource, 'owner') house = fields.ToOneField(DogHouseResource, 'house', full=True, null=True) bones = fields.ToManyField(BoneResource, 'bones', full=True, null=True, related_name='dog') class Meta: queryset = Dog.objects.all() resource_name = 'dog' authorization = Authorization()
class PersonResource(ModelResource): company = fields.ToOneField(CompanyResource, 'company', null=True, full=True) dogs = fields.ToManyField('related_resource.api.resources.DogResource', 'dogs', full=True, related_name='owner', null=True) class Meta: queryset = Person.objects.all() resource_name = 'person' authorization = Authorization()
class CompanyResource(ModelResource): address = fields.ToOneField(AddressResource, 'address', null=True, full=True) products = fields.ToManyField(ProductResource, 'products', full=True, related_name='producer', null=True) class Meta: queryset = Company.objects.all() resource_name = 'company' authorization = Authorization()
class TagResource(ModelResource): taggabletags = fields.ToManyField( 'related_resource.api.resources.TaggableTagResource', 'taggabletags', null=True) extradata = fields.ToOneField( 'related_resource.api.resources.ExtraDataResource', 'extradata', null=True, blank=True, full=True) class Meta: resource_name = 'tag' queryset = Tag.objects.all() authorization = Authorization()