Home > Net >  Django server returning a 404 out of nowhere
Django server returning a 404 out of nowhere

Time:07-28

I'm quite new to Django and coding to be honest!

I'm facing a problem that appeared out of nowhere when I was finishing a website I can't seem to find anything here that helps with my case.

The problem goes with when I try to run the server with python manage.py runserver it gives me this error :

 System check identified no issues (0 silenced).
July 27, 2022 - 17:30:51
Django version 4.0.6, using settings 'sitewilza.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /
[27/Jul/2022 17:30:53] "GET / HTTP/1.1" 404 2573
Not Found: /
[27/Jul/2022 17:30:57] "GET / HTTP/1.1" 404 2573

and the server returns this:

Page not found (404)
Request Method: GET
Request URL:    http://127.0.0.1:8000/
Using the URLconf defined in sitewilza.urls, Django tried these URL patterns, in this order:

admin/
sobremim [name='sobre']
formacao [name='formacao']
contato [name='contato']
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.

the problem is I did not change anything in both my urls.py, here they are :

from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('website.urls')),
]

&

from django.urls import path
from . import views 


urlpatterns = [
    path('sobremim', views.sobremim, name='sobre'),
    path('formacao', views.formacao, name='formacao'),
    path('contato', views.contato, name='contato'),
]

note that i was editing my contato.html file using a anchor to set up a Instagram forward link.

I don't know if my questing is well presented or not, but I hope you guys can understand and thank you in advance for your time in helping me.

CodePudding user response:

So see, you have to understand django flow cycle and then you will be able to develop your website properly.

Here is what you doing in your urls.py when you are requesting your django local server is you are calling urls.py of website app so but you are not telling django what to do exactly whem / is called.

This will fix your problem:

from django.urls import path
from . import views 


urlpatterns = [
    path('', views.sobremim, name='sobre'),
    path('formacao', views.formacao, name='formacao'),
    path('contato', views.contato, name='contato'),
]

Update your urls.py file of website app and you will get your response.

  • Related