Hey Friends,

I'm having trouble figuring out how to upload a document model to a 
dynamically generated location.  The following models.py file contains two 
models and a helper function


views.py


# 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)



Any comments about how to remedy this situation would be greatly 
appreciated.  

Thanks,
K

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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.

Reply via email to