Answer the question
In order to leave comments, you need to log in
Is there any advantage to using a decorator on models containing an ImageField?
Hello, I often see something like this in some code:
def contain_photos(model):
upload_path = model.__name__.lower() + 's'
image_field = models.ImageField(upload_to=upload_path)
setattr(model, 'photo', image_field)
@contain_photos
class Animal(models.Model):
pass
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question