On 2007-03-16 13:51:17 -0600, "johnny" <[EMAIL PROTECTED]> said:
> > I have a forms.py that uses newforms. It has a class > SalesForm(forms.Form). I need to pass an argument, p_id to SalesForm, > which is used to retrieve related product from product model. When I > run it, I get an error: > > Exception Type: TypeError > Exception Value: __init__() takes exactly 2 arguments (3 given) > > at 'form = forms.SalesForm(request.POST, p_id)', in view. > > In the view.py and forms.py, I have the following: > > forms.py: > > class SalesForm(forms.Form): > def __init__(self, p_id): > do some stuff here > > view.py: > > from apps.sales import forms > def forsale_add(request, p_id): > if request.method == 'POST': > form = forms.SalesForm(request.POST, p_id) > if form.is_valid(): > do my stuff here > return something > else: > form = forms.SalesForm(p_id) > return something > > Thank you. > > > Could you explain why you want to pass p_id into SalesForm. It sounds like there is a simpler solution to this as opposed passing it into the form class which shouldn't really care about p_id at all. -- Brian Rosner http://www.brosner.com/blog --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---