#15909: File Upload is not working for Django 1.2.1
---------------------------+--------------------------------------
Reporter: zerin@… | Owner: nobody
Type: Uncategorized | Status: new
Milestone: | Component: File uploads/storage
Version: 1.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
---------------------------+--------------------------------------
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
--
Ticket URL: <http://code.djangoproject.com/ticket/15909>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.