Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django manage.py runserver command requested resource was not found on this server error

Tags:

python

django

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)

Edit:

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.

myrms/view.py

from django.http import HttpResponse
# Create your views here.
def index(request):
    return HttpResponse("Hello,World. You're at the polls index.")

myrms/urls.py

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

like image 718
user11079079 Avatar asked Oct 18 '25 12:10

user11079079


1 Answers

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),
]
like image 175
meshy Avatar answered Oct 20 '25 03:10

meshy