1π
β
I think the code of the serializers isnβt correct.
class ChannelSerializer(serializers.ModelSerializer):
class Meta:
model = Channel
fields = '__all__'
class CategorySerializer(serializers.ModelSerializer):
channel = ChannelSerializer(many = True, read_only = True)
class Meta:
model = Category
fields = '__all__'
And in the html, some attributes donβt exist in the models. channel_set
should be changed into channel
and channel.title
into channel.channel
.
There are no names like channel_set
, title
in the models.
...
<ul>
<div>
{% for channel in category.channel %}
<li>Teste {{ channel.channel }}</li>
{% endfor %}
</div>
</ul>
...
Or you should modify the names in the models.
π€Metalgear
Source:stackexchange.com