Thank you for your response.

1. The fact that I'm using a function and then referencing the function in
the
        render should not make a difference.
2. I'm not using a database model.
3. Where is the redundancy?
4. When you respond to a request for help an example
      of how you would solve the problem whould help, that I is why
      I took the time to type in th the forms.py file, the views.py and the
html.
5. You don't need to respond to this.





On Tue, Mar 20, 2012 at 3:17 AM, Babatunde Akinyanmi
<tundeba...@gmail.com>wrote:

> Why not just do:
> useage = capital * tax_rate
> Instead of your projfin function. In the projfin function, the request
> you are passing is also redundant.
>
> As for the error, I don't know how you refactored your models code but
> obviously from the error message, you are not passing in ints. You can
> try to debug the code by printing capital and tax_rate so you can see
> what values are being passed into the function.
>
> On 3/19/12, Tim Ney <tm...@columbus.rr.com> wrote:
> > Rajeesh,
> >
> > Following your advice, Im think I've about solved the problem.
> > I've got one last exception, I hope.
> >
> > Here is the new iteration of views.py, all other files remain the same.
> > In short the page renders to the screen, the problem arises when values
> are
> > submitted
> > to the view.
> >
> > I get an exception  "can't multiply sequence by non-int of type 'tuple".
> > I've created a new
> > function that describes the multiplication operation, that is used within
> > the render function, this
> > is where the error occcrs. I'm not referencing the variables properly, I
> > guess.
> >
> > def calculation(request):
> >      """function that computes submission"""
> >     if request.method == 'POST':
> >          form = FinanceTable(request.POST)
> >          if form.is_valid():
> >            cd =form.cleaned_data
> >            capital = cd['capital'],
> >            tax_rate = cd['tax_rate'],
> >            useage = projfin(request, capital, tax_rate)
> >            response_dict = {'capital' : capital, 'tax_rate' : tax_rate,
> > 'useage' : useage}
> >            return render_to_response('textplusnumbers.html' ,
> response_dict)
> >    else:
> >          form = FinanceTable(
> >                       initial={'capital' : 1000, 'tax_rate' : .07}
> >                       )
> >
> >    return render_to_response('textplusnumbers.html' , {'form' : form})
> >
> > def projfin(request, capital, tax_rate):
> >      useage = capital * tax_rate
> >      return useage
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Mar 19, 2012 at 1:10 PM, Rajeesh Nair <rajeeshrn...@gmail.com
> >wrote:
> >
> >>
> >> Your FormClass expects all 3 fields to be optional (*required=False*).
> >> But your code in view always expects them to have integer values. And
> you
> >> end up multiplying values from two blank fields! Either you provide some
> >> default value to the fields or rewrite view to use
> >> *form.cleaned_data.get*with a default value as 2nd argument to it.
> >>
> >>
> >> On Monday, March 19, 2012 9:11:27 PM UTC+5:30, bolivar4 wrote:
> >>
> >>>
> >>>
> >>> "unsupported operand type(s) for *: 'NoneType' and 'NoneType'"
> >>>
> >>>
> >>> class FinanceTable(forms.Form):
> >>>        capital = forms.IntegerField(required=**False)
> >>>        tax_rate = forms.DecimalField(required=**False)
> >>>        useage = forms.IntegerField(required=**False)
> >>>
> >>  --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To view this discussion on the web visit
> >> https://groups.google.com/d/msg/django-users/-/CFfpFTLoPSMJ.
> >>
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Reply via email to