I have just today started working with django.
I tried executing the run server command but I keep encountering the Page not found error
.
I have been trying to debug the problem for almost an hour now.
Project rms > myrms (app)
I have initally doubly defined url patterns statement which was pointed out by meshy. I corrected that error but still the code is not working. Help.
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("Hello,World. You're at the polls index.")
from django.contrib import admin
from django.urls import include, path
from . import views
urlpatterns = [
path('', views.index,name = 'index'),
path('myrms/', include('myrms.urls')),
path('admin/', admin.site.urls),
]
It's expected to show the hello world statement but keeps on turning up Page not found error
on running manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
February 18, 2019 - 18:41:24
Django version 2.1.7, using settings 'RMS.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[18/Feb/2019 18:41:36] "GET /myrms/ HTTP/1.1" 404 77
I am trying to open. url"http://localhost:8000/myrms/" or "http://127.0.0.1:8000/myrms/" both are showing error
You're including this file, from this file recursively.
Remove this line, it's redundant because you're writing it from within myrms/urls.py
:
path('myrms/', include('myrms.urls')),
Change the URL of your view to match the URL you're accessing:
path('myrms/', views.index,name = 'index'),
Alternatively, access a different URL: http://localhost:8000/
Ensure that ROOT_URLCONF
is set to myrms.urls
.
Another old answer
You are using '^$'
, but that is for re_path()
, not path()
.
path('', views.index,name = 'index'),
Original answer, before question changed
You've defined urlpatterns
twice. The second time you define it, you override the first.
To correct this, combine the two lists:
urlpatterns = [
path('', views.index,name = 'index'),
path('myrms/', include('myrms.urls')),
path('admin/', admin.site.urls),
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With