quick question. I struggle with writing a conditional in model. If I use code below I get desired .png
file, but I'd like to specify that
if tripName == 'russia'
than do the condition. However when I add that line code goes immediately to the else. Any ideas?
Updated code!
tripImages = (
("Russia"),
("Italy"),
("France"),
)
class Trip(models.Model):
tripName = models.CharField(max_length=64)
tripLogo = models.ImageField(default="default_trip.png", upload_to='trip_pics')
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
if self.tripName in tripImages:
self.tripLogo = '{}.png'.format(self.tripName.lower())
else:
pass
tripImg = Image.open(self.tripLogo)
print(self.tripLogo)
if tripImg.height > 300 or tripImg.width > 300:
output_size = (300, 300)
tripImg.thumbnail(output_size)
tripImg.save()
Here is my code print
is added whether this function does anything, and it seems that yes. The name is changed, but the image is not swapped. Any ideas?