'ValueError: Field 'id' expected a number but got 'Abidjan'
Hello I'm new to django and I don't understand the following error: ValueError: Field 'id' expected a number but got 'Abidjan'. Here is the model code for more details:
class City(models.Model):
city = models.CharField(max_length=25)
date_create = models.DateTimeField(default=timezone.now())
def __str__(self) -> str:
return self.city
class District(models.Model):
district = models.CharField(max_length=25)
date_create = models.DateTimeField(default=timezone.now())
def __str__(self) -> str:
return self.district
class SliderSite(models.Model):
title_image = models.CharField(max_length=25, blank=False)
price = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(1_000_000)])
photo_profile = models.ImageField()
city = models.ForeignKey(City, on_delete=models.CASCADE)
district = models.ForeignKey(District, on_delete=models.CASCADE)
data_create = models.DateTimeField(default=timezone.now)
def __str__(self) -> str:
return self.title_image
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|