'Cannot Access the Local Host on Python 127.0.0.1:8000 in browser
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('products/'),include('products.urls') #this line
]
Hi,anyone. sorry to ask this kind of question but this my first time tryin' python.
Whats wrong with path('products/'),include('products.urls') ?
if i delete that line, i can run the local host in http://127.0.0.1:8000/ in my tutorial explain to add that line to access http://127.0.0.1:8000/products to show Hello World in browser, but if i ad that line, the result on me is problem loading page. With this error shown in terminal:
File "C:\Users\BinarK\PycharmProjects\PyShop\pyshop\urls.py", line 23, in <module>
path('products/'),include('products.urls')
TypeError: _path() missing 1 required positional argument: 'view'
Solution 1:[1]
I change it to path('products/', include('products.urls'))
and the result in the browser is:
Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/productsUsing the URLconf defined in pyshop.urls, Django tried these URL patterns, in this order:
admin/The current path, products, 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.
But it still did not run.
I went to Settings and changed the last line from Debug = True to False, but nothing changed and it was still not able to access the URL.
I am using Windows 11 and Python 3.9.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rici |
