here’s my form…
class PercentForm(forms.Form):
percent = forms.IntegerField()
here’s my view that uses this:
formx = PercentForm(request.POST or None)
if formx.is_valid():
px = Pxxx.objects.get(id = user.id )
pcx = formx.cleaned_data['percent']
pc = (float(pcx / 10)
px.percentage_instant = pc
px.save()
pxxx model
percentage_instant = models.FloatField()
so say my input is 3 it should store as 0.3 but it stores as 0. why is that? where may the error be? I cant seem to figure it out.
If
pcxis an integer thenpcx / 10will still be an integer on 2.x. Perhaps you meantfloat(pcx) / 10orpcx / 10.0.