[Answered ]-Django-tastypie foreign key trouble

2👍

Try this:

class PostResource(ModelResource):
    images = fields.OneToManyField(PostImageResource, 'images', full=True)
    class Meta:
        queryset = Post.objects.all()
        resource_name = 'post'

——- EDITED ——-

Hmm…

In Your model:

class PostImage(models.Model):
    post =  models.ForeignKey(Post, related_name="images")
    image = models.ImageField(upload_to='images', null=True, blank=True)
    description = models.CharField(max_length=100)
    order = models.IntegerField()

Note null=True and blank=True.

Leave a comment