[Django]-Getting _wrapped_view() takes at least 1 argument (0 given) on creation of a model

5👍

From errors you posted it looks like in fact UserProfile is not a model class, but some function (likely decorated). Review your codebase and make sure you don’t define function named UserProfile. Perhaps you have view function named UserProfile somewhere below in views.py ?

0👍

if form.is_valid():
    first_name = form.cleaned_data['first_name']
    last_name = form.cleaned_data['last_name']
    username = form.cleaned_data['username']
    email = form.cleaned_data['email']
    password = form.cleaned_data['password']

    reg = User.objects.create_user(
        username=username,
        password=password, 
        email=email
        ) 

    reg.is_active = True
    reg.first_name = first_name
    reg.last_name = last_name
    new_user = reg.save()

    // This will give the system seconds (time) to generate new id 
    // before giving to userprofile
    messages.info(request, "User successfully registered. Creating profile...")

    UserProfile.objects.create(user_id=new_user.id, other_field='')

    ............

Leave a comment