@@ -21,22 +21,22 @@ def __str__(self):
2121class About (models .Model ):
2222 title = models .CharField (max_length = 50 )
2323 description = models .CharField (max_length = 250 )
24- icon = models .CharField (max_length = 30 ) # Material Icon name
25-
24+ icon = models .CharField (max_length = 30 ) # Material Icon name
25+
2626 class Meta :
2727 verbose_name = 'About'
2828 verbose_name_plural = 'About'
29-
29+
3030 def __str__ (self ):
3131 return self .title
3232
3333
3434class Tag (models .Model ):
3535 name = models .CharField (max_length = 30 )
36-
36+
3737 def __str__ (self ):
3838 return self .name
39-
39+
4040
4141class Project (models .Model ):
4242 name = models .CharField (max_length = 100 )
@@ -45,13 +45,13 @@ class Project(models.Model):
4545 image = models .ImageField ()
4646 tags = models .ManyToManyField (Tag )
4747
48- # override the save method and
49- # use the Image class of the PIL package
48+ # override the save method and
49+ # use the Image class of the PIL package
5050 # to convert it to JPEG
5151 def save (self , * args , ** kwargs ):
5252 if self .image :
5353 filename = "%s.jpg" % self .image .name .split ('.' )[0 ]
54-
54+
5555 image = Image .open (self .image )
5656 # for PNG images discard the alpha channel and fill it with some color
5757 if image .mode in ('RGBA' , 'LA' ):
@@ -60,7 +60,7 @@ def save(self, *args, **kwargs):
6060 image = background
6161 image_io = BytesIO ()
6262 image .save (image_io , format = 'JPEG' , quality = 100 )
63-
63+
6464 # change the image field value to be the newly modified image value
6565 self .image .save (filename , ContentFile (image_io .getvalue ()), save = False )
6666 super (Project , self ).save (* args , ** kwargs )
@@ -73,18 +73,18 @@ class Contact(models.Model):
7373 address = models .CharField (max_length = 250 )
7474 email = models .CharField (max_length = 150 )
7575 phone = models .CharField (max_length = 20 )
76-
76+
7777 class Meta :
7878 verbose_name = 'Contact'
7979 verbose_name_plural = 'Contact'
80-
80+
8181 def __str__ (self ):
8282 return self .email
8383
8484
8585class Footer (models .Model ):
8686 copyright = models .CharField (max_length = 200 )
87-
87+
8888 class Meta :
8989 verbose_name = 'Footer'
9090 verbose_name_plural = 'Footer'
0 commit comments