django-allauth basic setup

newbieProgrammer picture newbieProgrammer · Apr 8, 2014 · Viewed 7.4k times · Source

I tried to follow the latest http://django-allauth.readthedocs.org/en/latest/#installation

urls.py file looks like:

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^accounts/', include('allauth.urls')),
)

settings.py file has:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    # Required by allauth template tags
    "django.core.context_processors.request",
    "django.contrib.auth.context_processors.auth",
    # allauth specific context processors
    "allauth.account.context_processors.account",
    "allauth.socialaccount.context_processors.socialaccount",
)

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",
    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend",
)
SITE_ID = 1

and i ran python manage.py syncdb but when i visit my localhost:8000/accounts/login/, it gives me Page Not Found (404). I also double checked what I did with a tutorial at: http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/ but I'm not sure what else to do to get a basic login screen to show up. Any pointers?

EDIT

here's the error on the page in addition to the Page Not Found 404

Using the URLconf defined in asa.urls, Django tried these URL patterns, in this order:
^admin/
^accounts/ ^ ^signup/$ [name='account_signup']
^accounts/ ^ ^login/$ [name='account_login']
^accounts/ ^ ^logout/$ [name='account_logout']
^accounts/ ^ ^password/change/$ [name='account_change_password']
^accounts/ ^ ^password/set/$ [name='account_set_password']
^accounts/ ^ ^inactive/$ [name='account_inactive']
^accounts/ ^ ^email/$ [name='account_email']
^accounts/ ^ ^confirm-email/$ [name='account_email_verification_sent']
^accounts/ ^ ^confirm-email/(?P<key>\w+)/$ [name='account_confirm_email']
^accounts/ ^ ^confirm_email/(?P<key>\w+)/$
^accounts/ ^ ^password/reset/$ [name='account_reset_password']
^accounts/ ^ ^password/reset/done/$ [name='account_reset_password_done']
^accounts/ ^ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$ [name='account_reset_password_from_key']
^accounts/ ^ ^password/reset/key/done/$ [name='account_reset_password_from_key_done']
^accounts/ ^social/

The current URL, accounts/profile/, didn't match any of these.

Answer

Alex picture Alex · Apr 8, 2014

Just to check: have you started your server?

python manage.py runserver

EDIT:

It looks like you're trying accounts/profile/, which isn't a registered URL. Does it still give an error if you go to localhost:8000/accounts/register?

Also, from the docs:

When I attempt to login I run into a 404 on /accounts/profile/

When you end up here you have successfully logged in. However, you will need to implement a view for this URL yourself, as whatever is to be displayed here is project specific. You can also decide to redirect elsewhere.

Looks like you need to write your own view for accounts/profile/

If you want, you can set your login redirect to a different page in settings.py. I.e.:

LOGIN_REDIRECT_URL = "/"

This would send you back to your homepage.