0

I have an nested sterilizer:

class LinkSerializer(serializers.ModelSerializer):
class Meta:
    model = Link
    fields = [
        'linkname',
        'linkurl'
    ]
 
class WorkSerializer(serializers.ModelSerializer):
links = LinkSerializer(
    many=True,
    # queryset = Link.objects.all()
)
class Meta:
    model = Work
    fields = [
        'firstname',
        'lastname',
        'links'
    ]

The django models look like this:

class Work(models.Model):
firstname = models.CharField("Имя", max_length=10, blank=True)
lastname = models.CharField("Фамилия", max_length=30, blank=True)
 
class Link(models.Model):
links = models.ForeignKey(Work, related_name='links', on_delete=models.CASCADE, blank=True)
linkname = models.CharField("linkname", max_length=100, blank=True)
linkurl = models.CharField("linkurl", max_length=100, blank=True)

The django rest framework outputs the following about Links:

Links: Lists are not currently supported in HTML input.

I realized that I need to work towards json For nested serializers, but it doesn't work out, so I ask for help, how would you deal with this problem. Thanks in advance to the one who will help

please take another look at the screenshot attached to the question

Json ??

0 Answers0