Opened 14 years ago
Closed 14 years ago
#15909 closed Uncategorized (worksforme)
File Upload is not working for Django 1.2.1
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | File uploads/storage | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Here is my url.py file:
#####################################
urlpatterns = patterns(,
(r'users/profile/$', user_profile),
)
#####################################
Here is my view file:
#####################################
def user_profile(request):
if request.method == 'POST':
forms = UserProfileForm(request.POST, request.FILES)
if form.is_valid():
return HttpResponse('message'+request.method)
else:
return HttpResponse('message'+request.method)
else:
forms = UserProfileForm()
variables = RequestContext(request, {
'form': forms
})
return render_to_response(
'test/profile.html',
variables
)
#####################################
Here is html file:
#####################################
<form enctype="multipart/form-data" class="form widget" method="post" action="/users/profile/">
{{ form.csrf_token }}
<header><h2>Profile Page</h2></header>
<section>
<fieldset>
<dl>
<dt></dt><dd><label>Your Picture Details</label>{{ form.pic_title }}
</dd>
<dt></dt><dd><label>Your Picture *</label>{{ form.file }}
</dd>
</dl>
</fieldset>
<hr />
<button class="button button-green" type="submit" name='submit-id' value="SAVE" >SAVE</button>
</section>
</form>
I get the following message after clicking the Save button:
TypeError at /users/profile/
init() takes exactly 2 arguments (3 given)
Request Method: POST
Request URL: http://localhost:8000/users/profile/
Django Version: 1.2.1
Exception Type: TypeError
Exception Value:
init() takes exactly 2 arguments (3 given)
Exception Location: D:\Python24\lib\site-packages\django\core\files\uploadedfile.py in init, line 30
Python Executable: D:\Python24\python.exe
Python Version: 2.4.4
Python Path: ['D:
Python24
Lib
site-packages
django
bin
django_bookmarks', 'D:
Python24
lib
site-packages
setuptools-0.6c11-py2.4.egg', 'D:
Python24
lib
site-packages
pygments-1.3.1-py2.4.egg', 'D:
Python24
lib
site-packages
simplejson-2.1.1-py2.4.egg', 'D:
Python24
lib
site-packages
markdown-2.0.3-py2.4-win32.egg', 'D:
Python24
lib
site-packages
django_admin_tools-0.4.0-py2.4.egg', 'D:
Python24
lib
site-packages
django_rbac-0.9-py2.4.egg', 'D:
Python24
lib
site-packages
py-1.4.1-py2.4.egg', 'D:
Python24
lib
site-packages
elementtree-1.2.7_20070827_preview-py2.4-win32.egg', 'D:
Python24
lib
site-packages
sphinx-1.0.7-py2.4.egg', 'D:
Python24
lib
site-packages
jinja2-2.5.5-py2.4.egg', 'D:
Python24
lib
site-packages
docutils-0.7-py2.4.egg', 'D:
Python24
python24.zip', 'D:
Python24
Lib
site-packages
django
bin
django_bookmarks', 'D:
Python24
DLLs', 'D:
Python24
lib', 'D:
Python24
lib
plat-win', 'D:
Python24
lib
lib-tk', 'D:
Python24', 'D:
Python24
lib
site-packages']
Server time: Wed, 27 Apr 2011 16:19:58 +0600
Attachments (2)
Change History (3)
by , 14 years ago
Attachment: | preview.png added |
---|
by , 14 years ago
comment:1 by , 14 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
File save works fine -- your example has multiple bugs in it. If you want to know what they are, please ask on django-users. Trac is for tracking defects in Django, not for resolving problems with your own code.