jma
jma

Reputation: 3779

Django django-custom-user and registration becomes no-op

Registration fails silently with django-custom-user

I'm switching from using the default registration model to a custom model (to drop username and just authenticate with email address). An existing user can login, but creating a new user fails silently now. I call url 'registration_register', I get the user create form I expect, I fill it in and click the submit button, and...the form redisplays with email but not password, no error, no user creation.

registration_form.html

{% extends "..." %}

{% block content %}
<form method="post" action="{% url 'registration_register' %}">
{% csrf_token %}
{{ form.email.errors }}
<label for="{{ form.email.id_for_label }}">mail</label> {{ form.email }}
<br>
{{ form.password1.errors }}
<label for="{{ form.password1.id_for_label }}">password</label> {{ form.password1 }}
<br>
{{ form.password2.errors }}
<label for="{{ form.password2.id_for_label }}">password</label> {{ form.password2 }}
<br>

<input type="submit" value="Create" />
<input type="hidden" name="next" value="{{ next }}" />
</form>

{% endblock %}

More background

I pip install django-custom-user and make the changes recommended here -- adding to INSTALLED_APPS, db sync (in fact, it's a new project, so db delete and create), and the couple code changes to use it. I've left 'registration' in INSTALLED_APPS.

Django (1.7.6)
django-custom-user (0.5)

My urls.py still points to registration.backends.default.urls.

url(r'^accounts/', include('registration.backends.default.urls')),

Upvotes: 0

Views: 101

Answers (2)

Thomas Gak-Deluen
Thomas Gak-Deluen

Reputation: 2971

Well the problem you face is that django-registration expects a username as well as a password and an email address. As you can see in the source code of django-registration

https://bitbucket.org/ubernostrum/django-registration/src/8f242e35ef7c004e035e54b4bb093c32bf77c29f/registration/backends/default/views.py?at=default#cl-74

If I were you I would simply create a simple form and use a FormView from django. After, in order to match django-registration you could do more research and try to fit django-registration with django-custom-user.

It could be that you create a class that inherits django-custom-user, or that you change the form or anything like that. Otherwise you could even fork django-registration and update it according to django-custom-user and then use it for your project and make it available on github as django-registration-custom-user

Upvotes: 1

Thomas Gak-Deluen
Thomas Gak-Deluen

Reputation: 2971

Have you tried python manage.py makemigrations and python manage.py migrate?

Also try displaying the form as form.as_p in order to get all fields and all errors displayed automatically. Forget about CSS for now.

Also what package is registration.backends.default.urls ? Because it is not django-custom-user

I hope this helps

Upvotes: 0

Related Questions