On Mon, Mar 19, 2012 at 11:41 AM, bolivar4 <[email protected]> wrote:
> Want to present users a form in which numbers are entered, then manipulated
> in a view and a calculated value is returned to the screen.
> After looking in the the Django book around the net this is what I have
> come, (it doesn't work) shows below.  So far, the three fields setup in
> forms.py render to the secreen, that is all I'm getting.
>
>
>
> I am getting this error in the django 404 exception page: "unsupported
> operand type(s) for *: 'NoneType' and 'NoneType'"
>
>
> It is purposely a  simple exercise, more interested  in technique of doing
> this so, I know this can be done in javascript, but I want to do this with
> python/django.
> Thank you to anyone who can help me out, this has been a problem all
> weekend.
>
> forms.py:
>
> from django import forms
>
> class FinanceTable(forms.Form):
>        capital = forms.IntegerField(required=False)
>        tax_rate = forms.DecimalField(required=False)
>        useage = forms.IntegerField(required=False)
>
> views.py:
>
> from django.shortcuts import render_to_response
>
> def  calculation(request):
>        """view that sets up form calculation"""
>        if request.method == 'POST':
>             form  = FinanceTable(request.POST)
>             if form.is_valid():
>                  capital = form.cleaned_data['capital']
>                   tax_rate = form.cleaned_data['tax_rate']
>                   useage = form.cleaned_data['capital'] *
> form.cleaned_data['tax_rate']
>                   response_dict = {'capital' : capital, 'tax_rate'  :
> tax_rate, 'useage' : useage}
>                   return render_to_response('focus_areas.html',
> response_dict)
>         else:
>               form = FinanceTable(
>                              initial={'capital' : 1000, tax_rate : .07}
>                )
>         return render_to_response('focus_areas.html', {'form' : form})
>
>
> html in template:
>           <form action="" method= "" method="post">
>                   <table>
>                           {{ form.as_table }}
>                   </table>
>                   <input type="submit" value = "Submit"/>
>           </form>
>
>
> Any help ios much appreciated.

What does your urls.py file look like.  If you are getting 404 then it
may not be finding your view.
-- 
Joel Goldstick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to