django - Getting a username and uploading files -



django - Getting a username and uploading files -

i'm using django upload files user.

when user uploads file, need grab username well, , add together model.

initially, doing hidden value of username, can changed (i'm looking @ you, inspect element!)

so, tried setting initial value i've read on here already.

def upload(request): if request.method == 'post': username = {'uploader': request.user.username} form = uploadform(request.post, request.files, initial=username)

however, maintain getting error returned uploader field wasn't set. form:

class uploadform(forms.modelform): title = forms.charfield(max_length=55) uploader = forms.charfield(widget=forms.hiddeninput(), max_length=25) description = forms.textinput() image = forms.imagefield() file = forms.filefield() class meta: model = packs fields = ('title', 'uploader', 'description', 'image', 'file')

there's no need send username @ all. have access in request.user.username, own code demonstrates. if can there in stage, can in post stage.

django file username uploading

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -