For the following code:
class Image(models.Model):
alt_name = models.CharField(max_length=200)
url = models.CharField(max_length=255, blank=True)
class Button(Image):
source = models.ImageField(max_length=1024, upload_to='buttons')
class Snapshot(Image):
source = models.ImageField(max_length=1024, upload_to='snapshots')
class Banner(Image):
source = models.ImageField(max_length=1024, upload_to='banners')
In the above cases, I want to upload each of the different kind to its own upload folder. For example, banners will go under a folder called banners
and snapshot will go under snapshots
. The above works as expected but I'm repeating the ImageField for each sub-class. Is the above the only way to achieve my goal or is there a DRYer method?