Answer the question
In order to leave comments, you need to log in
Django RelationShips how to connect correctly?
Hello, there are 2 tables
class Data(models.Model):
title = models.CharField(max_length=200, default=None, verbose_name="Заголовок")
def __str__(self):
return self.title
class DataDetail(models.Model):
name = models.CharField(max_length=200, default=None)
data = models.ForeignKey(Data, on_delete=models.CASCADE)
def __str__(self):
return self.name
class DataSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Data
fields = ('title')
class DataDetailSerializer(serializers.HyperlinkedModelSerializer):
item = ItemSerializer()
class Meta:
model = DataDetail
fields = ('name', 'data')
- here in the DataSerializer the array from "DataDetailSerializer' is not displayed in any way
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question