Django Allauth and urls
Question: I have a dev environment for a test of Django. I am running Python 3.5.2 out
of a "local" `pyenv` install. I have Django 1.10.2. I discovered the `allauth`
registration plugin yesterday and have been playing with it but have hit a
snag.

My site is "dev.my.domain.com". The intent is that there will not be any
"public" information on the production version of this site. The production
version will be called something like: "members.my.domain.com". So, I wonder
if it is possible for the "allauth" plugin to have all non-/adomn inbound
requests check for auth?

So, requests to:

  * dev.my.domain.com
  * dev.my.domain.com/foo
  * dev.my.domain.com/foo/../bar/...

should all be checked for auth. If not there then I assume "allauth" will
redirect to a login/signup page.

I have tried setting the `Members/urls.py` file as:

    
    
    from django.conf.urls import include, url
    from django.contrib import admin
    
    urlpatterns = [
        url(r'^$', include('allauth.urls')),
        url(r'^admin/', admin.site.urls),
    ]
    

but that bombs with a Page Not Found error and the `DEBUG` message:

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

I bowed to my ignorance and went back to the allauth docs and used their
default `urls` setting:

    
    
    from django.conf.urls import include, url
    from django.contrib import admin
    
    urlpatterns = [
        url(r'^accounts/', include('allauth.urls')),
        url(r'^admin/', admin.site.urls),
    ]
    

but that also bombs with a Page Not Found and a different message:

    
    
        Using the URLconf defined in Members.urls, Django tried these URL patterns, in this order:
        ^accounts/
        ^admin/
        The current URL, , didn't match any of these.
    

I think the rest of the "allauth" install was done correctly but I am missing
something.

Ideas?


Answer: In your _view.py_ file, you just need to do a little "filter" before giving
away the page to see if the user is authenticated.

An example for this will be:

    
    
    def myview(request):
        if request.user.is_authenticated():
             # do something if the user is authenticated, like showing a page.
        else:
            # do somthing else
    

Regrading the urls structure - just try to add /accounts/ to the url and the
404 page will show you all the end points if you are on Debug mode (DEBUG =
True). You can also find all urls for endpoints on the documentation.

Hope I understood your problem correctly :)

