I have a PIL function that checks the uploaded image resolution and resizes it to either a fulscreen resolution or banner resolution then saves it to the database. Now I need to add a model textfield that saves the values "fullscreen" or "banner" to the database table when the picture is saved. I have added the field to the model but I don't know where and how to update this.
Asked
Active
Viewed 19 times
1 Answers
0
You can bind your attribute that is to be derived to a function. Example: I have a Person model with fields fname and lname. I can derive a function :
class Person(models.Model):
lname = models.CharField(max_length=500, blank=False)
fname = models.CharField(max_length=500, blank=False)
def fullname(self):
return "%s %s"%(self.fname,self.lname)
name = property(fullname)
Whenever I do person.name
it will actually return a name by combining fname and lname.

Deepam Patel
- 190
- 6