+1  A: 

First, don't search the net for Django help. Search here only: http://docs.djangoproject.com/en/dev/

Second, the current user is part of Authentication.

http://docs.djangoproject.com/en/dev/topics/auth/#topics-auth

The user is recorded in the request. request.user

S.Lott
The first point is good (and I did get into trouble doing this). However as soon as you try and do something not covered in the django docs it leaves diving into the code as the next thing to do.
Stuart Axon
(and the code is kind of intimidating at first).
Stuart Axon
+4  A: 

The current user is stored in the request object, and you can't get that in a model method unless you pass it in from elsewhere - which you can't do in the upload_to function.

So you'll need to approach this in a different manner - I would suggest doing it at the form level. You can pass the request object into the form's __init__ method and store it in an instance attribute, where you can get to it in a custom upload handler. For documentation on upload handlers, look here.

Daniel Roseman
Cheers, I've just got this working... there could maybe more documentation on this - I had to dig into the django source (which was fairly readable), however as I'm still a django n00b this was a little scary.Once I get my djangosnippets account sorted I'll upload it there, in the meantime heres a link to the custom class I made:http://pastebin.com/f114b9d29
Stuart Axon
OK, this wasn't fully working (the form wasn't validating) - In the end I extended TemporaryFileUploadHandler to copy the file to the right location (in file_complete). I'm still not sure why it's so hard to find info on this.
Stuart Axon
Any pointers on what I need to do with the form ?
Stuart Axon
I only got part of this working, but the custom upload handler was saving stuff to the wrong place after .save was called... guess I need to learn more about django - for the moment I've given up on this, as I didn't get very far for quite a while on it.
Stuart Axon
+1  A: 

If you added a user field to the model, and have that attribute set before you performed an upload, then you could get the user in to your upload_location function via the instance attribute.

davetdog