django-registration: login form not actually authenticating?
SHxKM opened this issue · 2 comments
SHxKM commented
I'm using a (compatible) Custom User model. The registering part of django-registration is working perfectly. However, when I take the user to the log-in page from a navbar, The user is never really authenticated. If I put in a wrong password it will correctly through and error, but when username and password are correct, the user is simply redirected to the correct page, just without getting authenticated.
My register/urls.py
:
urlpatterns = [
# a custom RegistrationForm that works perfectly
url(r'^register/$',
RegistrationView.as_view(form_class=GeneralUserForm),
name='registration_register'),
url(r'^', include('registration.backends.hmac.urls')),
]
My register/templates/registration/login.html
:
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<form method="post" action=".">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Log in' %}" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
<p>{% trans "Forgot password" %}? <a href="{% url 'auth_password_reset' %}">{% trans "Reset it" %}</a>!</p>
<p>{% trans "Not member" %}? <a href="{% url 'registration_register' %}">{% trans "Register" %}</a>!</p>
{% endblock %}
Snippet from settings.py
:
# Setting custom User Model
AUTH_USER_MODEL = 'register.GeneralUser'
# for guardian to work
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', # this is default
'guardian.backends.ObjectPermissionBackend',
)
# Setting limit on days
ACCOUNT_ACTIVATION_DAYS = 7
dicato commented
Did you figure it out?
SHxKM commented
Oh yeah. It was a problem with my ifblock in the template: there's no such condition 'user.authenticated'.