hi,
I am facing error -
MultiValueDictKeyError at /profilesetting/ramuss
"Key 'name' not found in <QueryDict: {u'pic': [u'avnesh.jpeg']}>"
I am trying to upload image using dynamically(using javascript),
but when I click on upload button after selecting image, it's showing this
error.
my html page contain-
{% block scriptquery %}
<script>
function donefunction()
{
visibility='hidden';
return true;
}
};
</script>
{% endblock %}
{% block rightcontent %}
<div
style="width:210px;height:180px;margin-left:2em;margin-top:.50em;margin-bottom:.25em;padding:5px;border-color:#d9d9d9;border-width:3px;border-style:
solid;">
<div class="imageedit"
onclick="{uploadimage.style.visibility='visible'}">Update Image</div>
<img src="{{user.pic.url}}" style="width:200px;height:164px;">
</div>
<div id="uploadimage"
style="position:absolute;height:150px;width:350px;visibility:hidden;margin-left:.50em;background-color:#f1f1f1;paddin:5px;border-width:1px;">
<form method="POST" action="#">{% csrf_token %}
<input type="file" name="pic" style="width:150px;height:25px;"/>
<div align="right">
<input type="submit" id="done"class="small button" value="upload"
style="margin-top:30px;" onclick="return donefunction()">
</div>
</form></div><!-- this is the form div -->
{% endblock %}
views.py page -
def profilesetting(request,uname):
user=User.objects.get(username=uname)
bag=Bag.objects.filter(creator=user.username)
if request.method=='POST':
user.name=request.POST['name']
user.email=request.POST['email']
if request.POST['phone']!="":
user.phone=request.POST['phone']
user.about=request.POST['about']
user.website=request.POST['website']
user.location=request.POST['location']
user.save()
return
render_to_response('profilesetting.html',{'user':user,'bag':bag},context_instance=RequestContext(request))
models.py --
from thumbs import ImageWithThumbsField
from django.db import IntegrityError
from django.db import models
import datetime
class User(models.Model):
username = models.CharField(max_length=65, primary_key=True)
name = models.CharField(max_length=64)
dob = models.DateField()
gender_choices = (('m','male'),('f','female'))
gender =
models.CharField(max_length=1,choices=gender_choices)
email = models.EmailField(verbose_name='your e-mail')
permission =
models.DecimalField(max_digits=3,decimal_places=0,blank=True, null=True)
password = models.CharField(max_length=32)
phone = models.DecimalField(max_digits=11,decimal_places=0,
blank=True, null=True)
pic = ImageWithThumbsField(upload_to='images',blank=True,
null=True)
about = models.TextField()
profile_view = models.DecimalField(max_digits=8,decimal_places=0,
null=True)
location = models.TextField()
website = models.URLField(max_length=64,blank=True, null=True)
reputation = models.DecimalField(max_digits=8,decimal_places=0)
doj = models.DateField(auto_now_add=True)
def __str__(self):
#return
(self.name,self.dob,self.email,self.about,self.profile_view,self.location,self.website,self.tags,self.num_of_que_asked,self.num_of_que_answered,self.doj)
return (self.name)
def reg(self):
return (self.name,self.username)
def save(self,*args, **kw):
super(User,self).save(*args, **kw)
class Admin:
pass
please help me, I am unable to solve this problem.
thanks.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.