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
Post a Comment