Hi, I don't understand very well what you are trying, but the error is clear:
class SalesForm(forms.Form): def __init__(self, p_id): do some stuff here SalesForm constructor only expect one parameter plus the object itself (self). You are passing request.POST, and that parameter is not expected. I know is not too much help ... but not too many details about your model or why you are creating a custom Form ... By On 3/16/07, johnny <[EMAIL PROTECTED]> wrote: > > > 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. > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---