I can't create a new url on django
i've watched some tutorials on how to create a new simple url and for some reason it doesn't work, it looks like i didnt registred any urls even though i did.
i created an app called 'Login' and registered it in the "INSTALLED APPS" list on settings.py of django :
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Login.apps.LoginConfig',
]
then i created the function called 'home' on the views file of the app, to show a phrase on the page:
from django.shortcuts import render
from django.http import HttpResponse
def home(request):
return HttpResponse('Hello')
and then i created a new url path on the urls.py file of the project, without a name at first, just (""):
from django.contrib import admin
from django.urls import path
from Login.views import home
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home),
]
and when i use the (python manage.py runserver) command it just got back to the "success install" page of django, the one with the little rocket.
Then I tried using a name for the url ("home/"):
from django.contrib import admin
from django.urls import path
from Login import views
urlpatterns = [
path('admin/', admin.site.urls),
path('home/', views.home)
]
but when i access the (localhost:8000/home/) it says that such url wasn't found, thats the message i get from the page:
Page not found (404)
Request Method:GETRequest URL:http://127.0.0.1:8000/home/
Using the URLconf defined in setup.urls
, Django tried these URL patterns, in this order:
admin/
The current path, home/
, 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.
And thats the message i get from the terminal:
19/Jan/2025 11:33:11] "GET / HTTP/1.1" 200 12068
Not Found: /home/
[19/Jan/2025 11:33:16] "GET /home/ HTTP/1.1" 404 2189
Not Found: /home/
[19/Jan/2025 11:33:17] "GET /home/ HTTP/1.1" 404 2189
I also tried to put the DEBUG on False but it didnt changed nothing. I also tried creating a urls.py file on the app folder but it also didnt help. Please help me lol, im not a fluent in english so i hope i explained it well.