Trying to deploy my Django app on virtual shared server. All works as expected until I try to log in to the admin app. I think it may have something to do with the way that the server deals with posts (had a similar problem with Flask). The setup works fine on my local machine.
I can get to the admin login page, but when I submit my credentials I get a 404 error. In debug mode the response is:
Page not found (404)
Request Method: POST
Request URL: https://lindcraft.williesworkshop.com/admin/login/
Raised by: django.contrib.admin.sites.login
Using the URLconf defined in lindcraft.urls, Django tried these URL patterns, in this order:
admin/
^[P|p]roducts?/(?P<prod_id>\d{0,3})/$ [name='product']
^[P|p]rices?/?$ [name='prices']
^[P|p]arking [name='parkingIntro']
^[D|d]isplay [name='displayIntro']
^[C|c]ontact [name='contact']
^[A|a]bout [name='about']
^$ [name='index']
The current path, login/, didn't match any of these.
The project urls.py is:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('www.urls')),]
Django seems to be looking for "login/" instead of "admin/" even though the "request URL" is "... /admin/login/" The admin part is striped off somehow.
Funny thing is, the exception seems to be raised by django.contrib.admin.sites.login as though the request actually made it to admin.
It seems to me that the same URL works with a GET but not with a POST.
Can anyone offer any insight?
FWIW, my hosting service (a2hosing) uses something called passenger to manage python requests. There may, or may not be a ngnix server used too.
TIA!
Related
I'm following this tutorial:https://www.w3schools.com/django/django_views.php
After copying all the code to create the members and admin views I get this error:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Using the URLconf defined in myworld.urls, Django tried these URL patterns, in this order:
members/
admin/
The empty path 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.
In your project urls.py you set the path to the members app to use 127.0.0.1:8000/members
In order to navigate to 127.0.0.1:8000/members using the default route, you need to change the path to look like this :
path('', include('members.urls')),
Homepage doesn't load properly
I have successfully build and deployed my code in Heroku.
It works fine locally but react doesn't render the index.html
The backend API works properly here
but the homepage here doesn't load - using ReactJS.
My all GitHub codes are here inside the develop branch.
Followed this post steps to host the same.
The homepage does not have a proper URL or path defined.
For example, you can go here:
https://mangya.herokuapp.com/administrator/
Or here
https://mangya.herokuapp.com/api
...As they are valid URLs.
Your blank 'homepage' path is not listed so there is no view being hit thus you get the error.
To fix this you need to change your urls.py in MyBlog to look like this:
urlpatterns = [
path('', [path.to.your.view]),
path('administrator/', admin.site.urls),
path('api/', include(router.urls))
]
In Django for anything to be rendered when you hit a URL, you need to have a view defined that renders the template, this is what my example for your urls.py shows.
So for example, if you are trying to run a Vue, React, or any other frontend framework that would rely on an API and Ajax calls to populate a page, you must allow that base page to be rendered by Django as it is the server running your application.
Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/about/ Using the URLconf defined in
Hello.urls, Django tried these URL patterns, in this order:
admin/ admin/ [name='home'] service [name='service'] contact
[name='contact'] about [name='about'] The current path, about/, didn't
match any of these.[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/jZMW9.png
You are getting this warning because you haven't defined a pattern that will direct the user to that page. So if you are doing this in a new application or the root part? Inform us about that. Either way you should go to "urls" and add the path to that folder. You can use the default "admin/" to teach you. For examle delete admin and write "abc/" and when you write"/abc" to your browser it'll show up.
I'm trying to run this library. I downloaded and copied it on my desktop, then i tried to run it using:
py -3.7 manage.py runserver
I got:
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
But when i go to that url i keep getting this error:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Using the URLconf defined in django_google_authenticator.urls, Django tried these URL patterns, in this order:
^admin/login/$
^admin/
The empty path didn't match any of these.
I don't understand what's wrong, can someone help me? Thanks in advance!
I think thats the normal behavour of Django, as you can see it is saying that your path didn't match any of the configured ones, like admin, so why don't you try http://127.0.0.1:8000/admin/to access Django Admin login page.
If you want to see something different from a 404 with the base url you need to configure your urls and maybe add a redirect view, in that way when the base url is use it will redirect to your admin or other preferred page.
I am trying to learn Django and I am currently stuck in an issue.
I created an app Contact and run the server, I get the error.
The error page displayed by server:
The urls.py file in the app Contact
urls.py in conatct
When the pattern in urls.py is
urlpatterns =[url(r'^$', views.form, name ='form')]
it works properly, but not with other pattern shown in the picture
Your help would be greatly appreciated.
The Page not found error message tells you what went wrong: For the URL (/contact) you requested, Django was unable to find a suitable view. Because you have debugging enabled, you get some information, including a list of registered views.
First things first: You probably have url(r'^contact/', include('contact.urls')) somewhere in your top level urls.py. This makes the URLs defined in the contact/urls.py available under the prefix /contact.
With
urlpatterns = [
url(r'^form/', views.form, name='form'),
]
in contact/urls.py you are telling Django that you want urls starting with contact/form/ to be handled by views.form.
Consequently, when you access http://localhost:8000/contact/ in your browser, there is no view associated with that URL, hence the 404. Your view is reacting to to http://localhost:8000/contact/form, not http://localhost:8000/contact.
When you change the URL pattern to
urlpatterns = [
url(r'^$', views.form, name='form'),
]
you modify the URL views.form reacts to.