Righto -- unfortunately that's the best solution I've come up with to date. Here's the detailed version:
# models.py def get_upload_path(instance, filename): return "%s/%s/%s" % (instance.__class__.__name__.lower(), instance.uuid, filename,) def get_uuid(): import uuid return str(uuid.uuid4()) class MyModel(models.Model): ... pdf = models.FileField(max_length=200, upload_to=get_upload_path) uuid = models.CharField(max_length=36, default=get_uuid, editable=False) That results in <model_name>/<uuid>/<original_file_name>. I certainly did entertain a minimal-save-to-get-the-PK followed by the "real" save, but didn't even get as far as discovering that it could cause problems with shortcut functions. What turned me off at the outset was needing to provide fake or default values for every other field in the model, deleting that one if the "real" save failed, etc. Seemed like a lot of busywork and prone to error. Regards Scott On May 13, 10:52 pm, Richard Colley <richard.col...@gmail.com> wrote: > Exactly as you had described ... I wanted to upload images to paths > with the model instance's id in it. Seemed easier for a human to > relate to that way (in case of maintenance outside of django). > However, the uuid approach or similar may be the way forward. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.