I followed this guide to extend registration in Django and it all seemed working until I clicked register and nothing happens. I checked in the command line with sql
and table exists as per specification, however when I try to view items with UserProfile.objects.all()
it returns empty list. Seems like nothing is getting sent anywhere upon form submission.
I get no errors, so bit confused on what is the issue.
models.py
def user_registered_callback(sender, user, request, **kwargs):
profile = UserProfile(user = user)
profile.first_name = str(request.POST["first_name"])
profile.last_name = str(request.POST["last_name"])
profile.city = str(request.POST["city"])
profile.country = str(request.POST["country"])
profile.save()
user_registered.connect(user_registered_callback)
forms.py
from registration.forms import RegistrationForm
class CustomRegistrationForms(RegistrationForm):
first_name = forms.CharField(label ="First Name")
last_name = forms.CharField(label ="Last Name")
city = forms.CharField(label ="City")
country = forms.CharField(label ="Country")
urls.py
url(r'^accounts/register/$', RegistrationView.as_view(form_class = CustomRegistrationForms),
name = 'registration_register', kwargs=dict(extra_context={'next_page': '/services/'})),
url(r'^accounts/', include('registration.backends.simple.urls'))
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
registration_form.html
<form method="post" action="" class="wide">
{% csrf_token %}
..sample form
<label for="id_username">Username:</label>
{% if form.username.errors %}
<p class="errors">{{ form.username.errors.as_text }}</p>
{% endif %}
{{ form.username }}
<input type="submit" class="btn btn-default btn-sm" value="Register"></input>
</form>