Friday, November 21, 2014

Re: DecimalField returns 'This value must be a decimal number' when blank

Hi,

Could you post a traceback? Also, what database are you using?

Also also, ModelForms would help simplify your code. Check them out if you haven't.
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/

Thanks,
Collin


On Thursday, November 20, 2014 10:44:26 AM UTC-5, elcaiaimar wrote:
I' ve seen that south is for older django versions than 1.7, I continue having the same problem, I wonder if the issue will be in my views, when I save all the information, please, have a look to my code:

if 'formulariopozo' in request.POST:
        formulario = PozosForm(request.POST)
        if formulario.is_valid():
            titulo = 'Formulario de pozos'

            codpozo=request.POST['codpozo']
            x=request.POST['coorx']
            y=request.POST['coory']
            tipo=request.POST['tipo']
            cotatrapa=request.POST['cotatrapa']
            profundidad=request.POST['profundidad']
            cotafondo=request.POST['cotafondo']
            material=request.POST['material']
            materialpates=request.POST['materialpates']
            diametro=request.POST['diametro']
            largotrapa=request.POST['largotrapa']
            seccionmayor=request.POST['seccionmayor']
            seccionmenor=request.POST['seccionmenor']
            numacometidas=request.POST['numacometidas']
            origen=request.POST['origen']
            observaciones=request.POST['observaciones']

            pnt=Point(float(x),float(y))
            xy=Pozo(codpozo=codpozo, coorx=x, coory=y, tipo=tipo, cotatrapa=cotatrapa,
            profundidad=profundidad, cotafondo=cotafondo, material=material,
            materialpates=materialpates, diametro=diametro, largotrapa=largotrapa,
            seccionmayor=seccionmayor, seccionmenor=seccionmenor, numacometidas=numacometidas,
            origen=origen, observaciones=observaciones, geom=pnt)
           
            xy.save()

I've tried to put default=None or default=Decimal('0.00') in my models.py but it continues without working. I don't know what can I do

Thank you very much

El domingo, 16 de noviembre de 2014 18:51:43 UTC+1, elcaiaimar escribió:
Hello everybody, I've a problem with DecimalField at Forms. I've a long form in my template and I want to left some fields in blank. I've declared these fields with
required=False, but when I submit the form I receive this error: 'This value must be a decimal number'.

I've tried to declare blank=True, null=True in respective fields in models.py and make a syncdb but it continues without works

Does somebody know how could I solve this problem?

Thank you very much!

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c1cd4026-a18f-49b6-afaf-200a83602209%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment