Django Rest Framework 404 after browsable API login - django

I am following the Tutorial and everything else works fine. The only problem is that when I try to login using the Rest Framework browsable API, I get a 404 after the login:
Request URL: http://localhost:7000/accounts/profile/
Using the URLconf defined in shelter.urls, Django tried these URL patterns, in this order:
^times/
^admin/
^api-auth/
The current URL, accounts/profile/, didn't match any of these.
Times is the name of the app. The API login is redirecting to accounts/profile, I haven't set that url up so of course the response is a 404. I'm probably missing a simple and obvious step.

Related

Moved legacy classic asp web site to django app but having trouble with django URL redirect app - old URLs with parameters get 500 error

I moved a 20 year old classic asp web site to a django app recently. Google Search Console is showing 500 errors for tons of very old URLS with parameters like /somefile.asp?ID=1234&name=some-name. Most of these URLS I don't even care about - they are really old but would rather they result in 404 than 500. Some do relate to newer content and in theory I could redirect to new django pages but when I try to redirect them using the django redirect app, the site shows 500 errors - like the ? either stops the pages from ever getting to the redirect middleware or the redirect app doesn't like the "?". How can I redirect these urls so I don't get 500 errors? Is there a way in a view to say:
if the full url path is x
redirect to full url path y
I have looked all over stack overflow and elsewhere and can't find this exact problem or a way to write a view like this. I did try the solution here (exactly) because it seems closest to my issue, but it did not work for me for this exact problem: Django's redirects app doesn't work with URL parameters
An example would be /profiles/?adid=134&v=857
The error with debug true is:
DoesNotExist at /profiles/
BusinessCategory matching query does not exist....
So it is trying to match this URL:
path('<slug:slug>/', views.view_category_list, name='view_category_list'),
before it ever gets to the /?
Relevant view code:
def view_category_list(request, slug):
try:
category_detail = BusinessCategory.objects.get(slug=slug)
except BusinessCategory.DoesNotExist:
category_detail = None
if category_detail:
--code here is all working fine so removed it to get to the issue--
else:
raise Http404
I hoped raising the 404 would call up the redirect app to do its job at redirecting to a specific url but it doesn't - it just shows the custom 404 when debug is False. Anyway, the 404 is better than the 500 for SEO purposes but I still would prefer being able to actually redirect some of the URLs to relevant content.

Facebook Graph API add extra parameter to login url

is there any way to get back my users to the current page after they login and redirect to my callback url? for example my current page url is:
https://mydomain.test/post1
then my callback url is:
https:/mydomain.test/callback.php
I tried to add extra parameter to login url but got an error because of the Valid OAuth Redirect URIs url match. my url is dynamic so I need a way to set parameters that changes and start from there.

I have following messages

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/info
Using the URLconf defined in mysites.urls, Django tried these URL patterns, in this order:
^ ^$ [name='index']
^info/
^admin/
The current path, info, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Issue is that you have to use url(r'^$' or url(r'^ in your views and specify only full url in project dispatcher

save button not working in django

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/post/new/blog/home_page.html
Using the URLconf defined in school.urls, Django tried these URL patterns, in this order:
^admin/
^$ [name='home_page']
^about/$ [name='about']
^event/$ [name='event']
^calendar/$ [name='calendar']
^contact/$ [name='contact']
^class_a/$ [name='class_a']
^login/$ [name='login']
^login_submit/$ [name='login_submit']
^class_info/$ [name='class_info']
^Ist_std/$ [name='Ist_std']
^IInd_std/$ [name='IInd_std']
^IIIrd_std/$ [name='IIIrd_std']
^IVth_std/$ [name='IVth_std']
^post/new/$ [name='post_new']
The current URL, post/new/blog/home_page.html, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Your URL is not matching any of your defined URLs. If you want that page to show anything, you'll need to include a match like:
r'^/post/new/blog/home_page$'
In url.py and write a view for it to display the wanted html file.

Url error in django social auth

I am using django social auth in my app and I found a Page not found error.
I have installed it in my app and also place it in my project parallel to my app.
And I have also add url to my url file
url(r'', include('social_auth.urls')),
But when it shows me the error It shows the list of url in my url file and where i have the required url which i am looking for.
The error page is as :
Page not found (404)
Request Method: GET
Request URL: http://abc.com/login/
Using the URLconf defined in webdev.urls, Django tried these URL patterns, in this order:
^$ [name='home']
^polls/
^admin/doc/
^admin/
^register1/
^edit/
^edit1/
^customerreg/
^checkout/
^checkout1/
^order/
^order1/
^upload/
^upload1/
^product/
^profile/
^logout/
^login/(?P<backend>[^/]+)/$ [name='socialauth_begin']
^complete/(?P<backend>[^/]+)/$ [name='socialauth_complete']
^associate/(?P<backend>[^/]+)/$ [name='socialauth_associate_begin']
^associate/complete/(?P<backend>[^/]+)/$ [name='socialauth_associate_complete']
^disconnect/(?P<backend>[^/]+)/$ [name='socialauth_disconnect']
^disconnect/(?P<backend>[^/]+)/(?P<association_id>[^/]+)/$ [name='socialauth_disconnect_individual']
The current URL, login/, didn't match any of these.
In the above list you can see that url file have that url , but it doesn't access that ??
^login/(?P<backend>[^/]+)/$ [name='socialauth_begin']
This url do not match with http://abc.com/login/ as the url pattern requires a backend parameter.
Something like this will match the url you are accessing, however there is no backend parameter there, so in view you may want to choose something default.
url(r'^login/$', 'your_view',),