Whenever I start a project in Django, independently of the name of the app or project, and irrespective of any urls or settings configuration, upon running python manage.py runserver and navigating to 127.0.0.1 I get the following error: Not Found: /ball/ [10/Jan/2022 11:32:32] "GET /ball/ HTTP/1.1" 404 2337 and this displays in th browser:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/ball/
Using the URLconf defined in ornaments.urls, Django tried these URL patterns, in this order:
admin/
^static/(?P<path>.*)$
^media/(?P<path>.*)$
^static/(?P<path>.*)$
The current path, ball/, 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.
Why is Django looking for a route called ball?
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')),
views.py
from django.urls import path, re_path
from blog import views
app_name = 'blog'
urlpatterns = [
path('archive/<int:year>/<str:month>/<int:day>/',
views.PostDAV.as_view(), name='post_day_archive'),
path('archive/today/', views.PostTAV.as_view(), name='post_today_archive'),
]
urls.py
from django.views.generic.dates import DayArchiveView, TodayArchiveView
from blog.models import Post
class PostDAV(DayArchiveView):
model = Post
date_field = 'modify_dt'
class PostTAV(TodayArchiveView):
model = Post
date_field = 'modify_dt'
error code
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/blog/archive/today/
Raised by: blog.views.PostTAV
No posts available
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.
When using DayArchiveView, template is opened, but 404 error occurs when using TodayArchiveView.On the official website of the library (https://docs.djangoproject.com/en/3.0/ref/class-based-views/generic-date-based/), I'm sure TodayArchiveView and DayArchiveView have the same template name, but why does 404 error occur only when I use TodayArchiveView? Why does the TodayArchiveView alone have 404 errors when both use the same template? Just in case, I named the template for TodayArchiveView as something else and tried using another template, but there is still a 404 error. Is there anything I missed? I'm sorry for my poor English.
stack trace
System check identified no issues (0 silenced).
May 20, 2020 - 12:05:42
Django version 3.0.6, using settings 'myblog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /
[20/May/2020 12:05:45] "GET / HTTP/1.1" 404 2135
[20/May/2020 12:05:51] "GET /blog/archive/ HTTP/1.1" 200 771
Not Found: /blog/archive/today/
[20/May/2020 12:05:57] "GET /blog/archive/today/ HTTP/1.1" 404 1731
The first 404 error occurred because I haven't set up the homepage yet. Please ignore it.
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/polls/'polls/index.html
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
admin/
^polls/ ^$ [name='index']
^polls/ ^(?P<question_id>[0-9]+)/$ [name='detail']
^polls/ ^(?P<question_id>[0-9]+)/results$ [name='results']he current path, polls/'polls/index.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 problem is not about IDE, you need to properly configure your urls.py page. It seems like Django couldn't find 'polls/'polls/index.html' address. You need to go to urls.py file and add following line;
path('polls/'polls/index.html/', views.path_to_function, name='index'),
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.
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!