4👍
✅
You don’t have a route defined for the empty path (i.e. http://<hostname>/
). When you include another app’s URL definitions, the two paths are concatenated, so currently the only valid paths in your project are:
'' (from main urls.py) + '/MyApp/' (from app/urls.py)
'admin/` (from main urls.py)
Change the following line
path('MyApp/', views.MyApp, name='MyApp'),
to
path('', views.MyApp, name='MyApp'),
1👍
To connect Django views and URLs, you need to define a URL pattern for each view in your urls.py
file.
# views.py
from django.http import HttpResponse
def hello_world(request):
return HttpResponse("Hello, World!")
# urls.py
from django.urls import path
from .views import hello_world
urlpatterns = [
path('hello/', hello_world, name='hello_world'),
]
- [Django]-Jquery mobile and dynamic page content
- [Django]-Add reply to address to django EmailMultiAlternatives
- [Django]-Django – add a POINT in a PostgreSQL database using GeoDjango from decimal coordinates
Source:stackexchange.com