Instead of passing prefix as an argument, you could set it as an
attribute of your models. Something like this:
class User(AbstractUser):
prefix = "mugshot"
mugshot = models.ImageField('AB', upload_to= generate_attachment, ...)
then generate_attachment would be something like that:
def generate_mugshot(instance, filename):
filename, ext = os.path.splitext(filename)
return "%s/%s/%s%s" % (instance.prefix,
instance.id, uuid4(), ext)
Should work
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
django-users...@googlegroups.com.
> To post to this group, send email to
django...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/django-users.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/django-users/e11aa79e-a103-4b5e-8420-371599d4a7eb%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
--
Cordialement, Coues Ludovic
+336 148 743 42