I have Model, like:
def SomeModel(models.Model):
serial_num = models.IntegerField(unique=True)
count = models.IntegerField()
And have to create 2 url which will work with this model. But, there are have to be 2 different serializers. For example:
- For first url user’data have to has both fileds (serial_num and count) For second url users’data have to has only one field (count).
- In second case serial_num will be generated in Serializers class.
Is this good practice to make 2 different serializers for one model?
And also question, what about validation?
Field “count” is depends on another model. I thought put validate into serializer class. But I don’t want to have 2 the same blocks of validation code in 2 different serializers classes (for both urls).