json - Django rest-framework + polymorphic: serialize a list of URLs -


the relevant parts of model:

class item(polymorphicmodel):     rating = models.decimalfield(default=0.0, max_digits=5, decimal_places=2)     picture = models.urlfield(max_length=200)     category = models.foreignkey('category', related_name='items')     # url_list  class movie(item):     title = models.charfield(max_length=200)     description = models.charfield(max_length=2000)     ... 

i have list of urls in item class. list should serialized in movie object serializer.

so far tried create model represent url way:

class url(models.model):     url = models.urlfield(max_length=200)     item = models.foreignkey('item', related_name='pictures') 

but empty list when movie serialized. serializers are:

class urlserializer(serializers.modelserializer):      class meta:         model = scrollerpictureurl         fields = ('url',)   class movieserializer(serializers.modelserializer):     urls = urlserializer(many=true)      class meta:         model = movie         exclude = ('polymorphic_ctype', 'category') 

i need know how serialize url list movie object it's not empty.

that's did finally:

class movieserializer(serializers.modelserializer):     urls = serializers.slugrelatedfield(many=true, slug_field='url')      class meta:         model = movie         exclude = ('polymorphic_ctype', 'category') 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -