# I would like the string inputs to be self.bundle.user, and self.bundle.name where self is the document model. I know this doesn't work which is why I am here asking this question.
def get_user_document_directory():
document_directory = 'media/{0}/{1}/documents/'.format( ____, _____ )
return document_directory
class Bundle(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=100)
class Document(models.Model):
bundle = models.ForeignKey(Bundle)
name = models.CharField(max_length=100)
description = models.CharField(max_length=100)
document = models.FileField(upload_to=get_user_document_directory(self) ) # I know passing self doesn't work but just trying to get the point across of what I am trying to do.
uploaded_at = models.DateTimeField(auto_now_add=True)
| Argument | Description |
|---|---|
instance | An instance of the model where the In most cases, this object will not have been saved to the database yet, so if it uses the default |
filename | The filename that was originally given to the file. This may or may not be taken into account when determining the final destination path. |
--
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+unsubscribe@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/71125202-9b89-4572-a086-ab9fed2b4d01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.