title: Update record using model form in django
body: <p>HI I am updating an existing record, but everytime I do, its is saying 
  <code>Truncated incorrect DOUBLE value: 'user1'</code>
  I am pasting my view and models here. Please help me</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>class BasicDetails(models.Model):
     username = models.OneToOneField(User)
     name = models.CharField(max_length = 100, verbose_name = "Name")
     sex = models.CharField(max_length = 10, verbose_name = "Sex", choices = GENDER_CHOICES)
     dob = models.DateField(verbose_name = "Date of Birth")
  
     class Meta:
        db_table = u'wed_basicdetails'
     def __unicode__(self):
           return u'%s' % (self.username)
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>def editbasicdetails(request):
    if request.method == 'POST':
        username = User.objects.filter(username = request.user)
        instance = get_object_or_404(User, username = username)
        form = EditBasicDetailsForm(request.POST,instance=instance)
        if form.is_valid():
            form.save()
        return HttpResponseRedirect('/myprofile/')
    else:
        form = EditBasicDetailsForm(request.user)
    return shortcuts.render_to_response('editbasicdetails.html',locals(),
                                      context_instance = context.RequestContext(request))
  </code></pre>
  
  <p><strong>Model Form</strong></p>
  
  <pre><code>class EditBasicDetailsForm(forms.ModelForm):
    def __init__(self,user, *args, **kwargs):
        super(EditBasicDetailsForm, self).__init__(*args, **kwargs)
  
        userid = User.objects.filter(username = user).values('id')[0].get('id')
        self.fields['username'] = forms.CharField(initial = user,
                                                widget = forms.TextInput(attrs = {'readonly':'readonly'}))
    class Meta:
        model = BasicDetails
  </code></pre>
  
  <p>In the above view, I am not passing the username I am just getting the username value from <code>request.user</code> I am not sure what I am making wrong on this simple functionality. </p>
  
  <p>-Vikram</p>