Having my class Plug
class Plug(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
station = models.ForeignKey(Station, related_name="plugs", on_delete=models.CASCADE)
ocpp_name = models.CharField(max_length=50, null=True, blank=True)
I defined a unique_together
relationship as below in the Plug model :
class Meta:
unique_together = ('station', 'ocpp_name',)
The strange thing is that every time I try to create a new plug instance in a specific station given the ocpp_name
I got the error attached in the screenshot.
The stack trace raises no error, just a 400 Error response
How can i solve that? Is that related with the serializer of the Plug
model?
question from:
https://stackoverflow.com/questions/65951940/how-to-solve-non-field-errors-error-concerning-unique-together-relationship 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…