How can i create unique together based on a field in Django

This is my code

class Address(models.Model):
    customer = models.ForeignKey(Customer, related_name='addresses',
                                 on_delete=models.CASCADE)
    lat = models.FloatField()
    long = models.FloatField()
    class Meta:
        constraints = [
            UniqueConstraint(fields=['lat', 'long'], name='lat_long_unique')

I want the field lat long unique together but just with the same customer, how can i achieve that?

Back to Top