views:

30

answers:

1

During user registration I'm calling some custom function :

def user_created(sender, user, request, **kwargs):
    form = ExtendedRegistrationForm(validateemail=True, request.POST, request.FILES)

When requesting a form I need to give additional bool argument validateemail. This though give me error :

Exception Type: SyntaxError at / Exception Value: ('non-keyword arg after keyword arg', ('/home/myapp/regbackend.py', 59, None, 'form = ExtendedRegistrationForm(dontvalidateemail=True, request.POST, request.FILES)\n'))

What am I doing wrong ? Also if I'd like to use this argument in my form, do I need to add a custom init method? Like :

def __init__(self, *args, **kwargs):
    try:
        validate = args['validate']
    except:
        pass           
    if not validate:
        validate = False           
    super(ExtendedRegistrationForm, self).__init__(*args, **kwargs)
+1  A: 

Keyword arguments have to go after position arguments. Try:

form = ExtendedRegistrationForm(request.POST, request.FILES, validateemail=True)
mipadi
ok, and what about modifying the init method ? Should I do it in this way : __init__(self, request, **args, **kwargs) or differently ?
muntu
Not necessary; you could follow the same signature at the parent class, except with the added `validateemail` parameter.
mipadi