0

我知道有很多问题和很多答案,我试图得到我的问题的答案,但我找不到它,或者可能存在但我无法理解它。

我有这个models.py

class Clientspin(models.Model):
    id_client = models.AutoField(primary_key=True)
    login = models.CharField(max_length=20L, unique=True)
    account_state = models.DecimalField(max_digits=14, decimal_places=4)

    class Meta:
        db_table = 'clientspin'

    def __unicode__(self):
        return self.login, self.id_client

我有一个简单的forms.py

from django import forms

class ClientspinForm(forms.Form):
    login = forms.CharField(widget=forms.TextInput())
    money = forms.CharField(widget=forms.TextInput())

    def clean(self):
        return self.cleaned_data

这是我的views.py

from django.shortcuts import render_to_response
from django.template import RequestContext
from ceropin.forms import ClientspinForm
from ceropin.models import Clientspin

def index_register(request):
    if request.method == "POST":
        form = ClientspinForm(request.POST)
        info = "inicializando"

        if form.is_valid():
            login = form.cleaned_data['login']
            dinero = form.cleaned_data['dinero']
            client = Clientspin()
            client.login = login
            client.account_state = dinero
            client.password = ('crp'+login)
            client.save()
            info = "Se guardo satisfactoriamente"
        else:
            info = "Datos incorrectos"
            form = ClientspinForm()
            ctx  = {'form': form, 'informacion': info}
    else:
        form = ClientspinForm()
        ctx  = {'form': form}

    return render_to_response('registro/registro.html',ctx,context_instance=RequestContext(request))

如何更新具有相同登录名的记录的货币字段?

4

0 回答 0