Bino Oetomo
Bino Oetomo

Reputation: 625

how to properly write urls.py in django 3.2?

I knew there is so many question and solution about how to properly writing urls.py dan views.py

But still I can not solve my problem. my django version is 3.2

Here is my project urls.py

from django.contrib import admin
from django.urls import path, include
admin.site.site_header = 'Catat Kolam'
admin.site.site_title = 'CatatKolam'

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

Here is my app's urls.py

from django.urls import path

from . import views

urlpatterns = [path('helloworld', views.helloworld , name='helloword')]

Here is my views.py

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def helloworld(request):
    return HttpResponse("Hello world")

But still I got



Using the URLconf defined in proj.urls, Django tried these URL patterns, in this order:

    admin/ [name='index']
    admin/ login/ [name='login']
    admin/ logout/ [name='logout']
    admin/ password_change/ [name='password_change']
    admin/ password_change/done/ [name='password_change_done']
    admin/ autocomplete/ [name='autocomplete']
    admin/ jsi18n/ [name='jsi18n']
    admin/ r/<int:content_type_id>/<path:object_id>/ [name='view_on_site']
    admin/ auth/group/
    admin/ auth/user/
    admin/ catatkolam/konfig/
    admin/ catatkolam/kolam/
    admin/ catatkolam/bahandasar/
    admin/ catatkolam/bahancampuran/
    admin/ catatkolam/tebar/
    admin/ catatkolam/monitoring/
    admin/ ^(?P<app_label>auth|catatkolam)/$ [name='app_list']
    admin/ (?P<url>.*)$

The current path, admin/catatkolam/helloworld, matched the last one.

Kindly please give me any clue to fix ths problem

Sincerely
bino

Upvotes: 0

Views: 702

Answers (1)

usman imtiaz
usman imtiaz

Reputation: 714

urlpatterns = [path('helloworld', views.helloworld , name='helloword')]

remove this 'helloworld'

urlpatterns = [path('', views.helloworld)]

now it will work

Upvotes: 3

Related Questions