[Fixed]-Django user signup / registration form not working

1๐Ÿ‘

โœ…

As correctly pointed out by Nikhil, you are trying to serialize a form instance. Instead, you should serialize the form data.

From the Django Docs:

Whatever the data submitted with a form, once it has been successfully
validated by calling is_valid() (and is_valid() has returned True),
the validated form data will be in the form.cleaned_data dictionary.

Also, form.cleaned_data will not be available if is_valid() does not return True. You can instead use request.POST

Instead of:

    data = {'form': form, 'success': 'success'}
else: data = {'form': form, 'error': 'error'}

You want to do:

    data = {'form': form.cleaned_data, 'success': 'success'}
else: 
    data = {'form': request.POST, 'error': 'error'}
๐Ÿ‘คAnkur Gupta

Leave a comment