1

class Core:

    def logo_path(instance, filename):
        pattern = re.compile(r's+')
        filename = re.sub(pattern, '', filename)
        return 'images/core/logos/core_{0}/{1}'.format(instance.pk, filename)

    name = models.CharField(db_index=True, max_length=255)
    logo = models.ImageField(upload_to=logo_path, blank=True, null=True)

|

    2

    2

    |
      1

      |