Django can't find social auth url pattern - python

I have tried to set up social authentication for steam login button. I have followed all these steps, and added steam necessary stuff: adding API key to settings and steam.SteamOpenId to authentication backends.
The error:
Using the URLconf defined in Test.urls, Django tried these URL patterns, in this order:
^ ^$ [name='index']
^login/(?P<backend>[^/]+)/$ [name='begin']
^complete/(?P<backend>[^/]+)/$ [name='complete']
^disconnect/(?P<backend>[^/]+)/$ [name='disconnect']
^disconnect/(?P<backend>[^/]+)/(?P<association_id>[^/]+)/$ [name='disconnect_individual']
^admin/
Hyperlink i used to make login button:
Login
urls.py file of project:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^', include('Home.urls')),
url('', include('social.apps.django_app.urls', namespace='social')),
url(r'^admin/', admin.site.urls),
]
urls.py file of application Home:
from django.conf.urls import url
from . import views
app_name = 'Home'
urlpatterns = [
url(r'^$', views.index, name='index'),
]
Full Project Here.
I am wondering if there is still something that i need to set up, do i need to add views to url patterns? If so, then which? where is social authentication urls file located?

Related

AuthFailed at /oauth/complete/github/ Error in Django for social login

Authentication failed: The redirect_uri MUST match the registered callback URL for this application.
I have registered i my github account and the callback url i have set is: http://localhost:8000/oauth/complete/github/ and homepage url http://localhost:8000/ but the error is still there. and redirect Url in settings.py LOGIN_REDIRECT_URL = 'home'
I have tried many other techniques please help me out
my urls.py
from django.contrib import admin
from django.urls import path,include
from django.conf.urls.static import static
from django.conf import settings
from developer import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home_view, name='home'),
path('profileEdit',views.profile_edit_form,name='profileEdit'),
path('accounts/', include('accounts.urls')),
path('<int:pk>', views.profile_view, name='profileview'),
path('invites/', views.invites_view, name='invitesview'),
path('invites/<int:pk>', views.inviter_view, name='inviterview'),
path('oauth/', include('social_django.urls', namespace='social')),
]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)

How to fix url in python custom login

I have 2 django app. user and management. I have added dashboard/ in main app urls which redirects to user app urls. For this we need to login. All urls in user app is: dashboard/ and for login dashboard/login
but it shows error in /login.
ERROR:
Page not found (404)
Request Method: POST
Request URL: http://localhost:8000/login
Main app urls.py
from user import urls as user_urls
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('dashboard/', include(user_urls))
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
User app urls.py
from django.urls import path, include
from nh_user import views as users_views
from management import urls as management_urls
urlpatterns = [
path('login', users_views.user_login, name='user-login'),
path('logout', users_views.user_logout, name='user-logout'),
path('dashboard/', include(management_urls)),
path('', users_views.index, name='user-index'),
]
You specified dashboard/ as the route for all the urls in your users app. Django won't look for these urls unless you include '/dashboard/' in your address bar.
Currently the working path is http://localhost:8000/dashboard/login.
If you want to change your login path to http://localhost:8000/login you need to remove 'dashboard/' as the route in your project urls.py.
from user import urls as user_urls
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include(user_urls))
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
All the routes for the urls in your users app will now be at directly at http://localhost:8000/route-name without anything preceding them.

URL encoded characters on clicking link and page not found

I am getting the following error using Django 2.1:
Page not found (404)
Request Method: POST
Request URL: http://localhost:8000/user-accounts/%5Eregister/
Using the URLconf defined in my_project.urls, Django tried these URL patterns, in this order:
admin/
user-accounts/ ^register/$ [name='register']
user-accounts/ ^login/$ [name='login']
user-accounts/ ^logout/$ [name='logout']
bank-accounts/
The current path, user-accounts/^register/, didn't match any of these.
When I click a link in the header set in my base.html, I get the strange url http://localhost:8000/user-accounts/%5Eregister/ in browser. The links in base.html are:
<li class="dropdown-header">Register</li>
<li class="dropdown-header">Login</li>
The user accounts app urls.py:
from django.urls import path
from django.contrib import admin
from . import views
app_name = 'user-accounts'
urlpatterns = [
path(r'^register/$', views.register, name='register'),
path(r'^login/$', views.user_login, name='login'),
path(r'^logout/$', views.user_logout, name='logout'),
]
The project urls.py:
from django.contrib import admin
from django.urls import path, include
from user_accounts.views import register
urlpatterns = [
path('admin/', admin.site.urls),
path('', register),
path(r'user-accounts/', include('user_accounts.urls')),
path(r'bank-accounts/', include('bank_accounts.urls')),
]
Django's new (>=2.0) path() function does not work with regular expressions. That's why the ^ character is literally prepended to the URL.
If you want to keep using regular expressions, use the re_path() function.

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order

I have a problem with Django. Actually I want to create a login panel in my new site but when I try to write address the debugger respond me a error:
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/account/login
Using the URLconf defined in firmowa.urls, Django tried these URL patterns, in this order:
admin/
^account/
The current path, account/login, didn't match any of these.
My firmowa.urls is
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path(r'^account/', include('account.urls')),
]
And the project urls.py is:
from django.urls import path
from . import views
urlpatterns = [
path(r'^login/$', views.user_login, name='login'),
]
I'm looking a solution from few hours but still nothing.
path is a new feature in Django 2.0 and works different than the old url. Don't use regex in path. If you need regex, use re_path instead, but in your case there's no need for that.
Change your code to:
urlpatterns = [
path('login/', views.user_login, name='login'),
]
etc. and it should work.
More on the topic here and here.
from django.urls import path
from . import views
from django.conf.urls import url
urlpatterns = [
url( r'^$', views.index , name='index') ,
]

Django URLconf error

I am trying to build a website with Django. I am new to Django and have followed the Tango with Django tutorial.
I keep getting an URlconf error I do not understand.
I have a domain (www.example.com), an app (mainApp) and two views in mainApp (homePage, registration).
I want
http://www.example.com to be matched with the homePage view
http://www.example.com/registration/ to be matched with the registration view.
My urls.py file for the project is
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns(
'',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('mainApp.urls')),
)
The urls.py file for mainApp is
from django.conf.urls import patterns, url
from mainApp import views
urlpatterns = patterns(
'',
url(r'^$', views.homePage, name='homePage'),
url(r'^registration/$', views.registration, name='registration'),
)
This configuration displays the homePage view correctly, but not the registration view. The error is:
Using the URLconf defined in myProject.urls, Django tried these URL
patterns, in this order:
^admin/
^$
^/
The current URL, registration/, didn't match any of these.
What causes the error?
It looks fine. If you're hosting it online you should restart the webapp, if hosting it locally then restart the local host. Without restarting it the changes don't register.

Categories

Resources