ERROR 404 Django project has a wrong current path

I was creating a basic website following this tutorial:

https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/skeleton_website

When I tried to redirect the home page to my django app called unihub this error prompted:

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

admin/
unihub/
^static/(?P<path>.*)$
The current path, catalog/, didn’t match any of these.

My files look like this:

/TFGsWeb/settings.py

INSTALLED_APPS = [
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘unihub.apps.UnihubConfig’,
]

ROOT_URLCONF = ‘TFGsWeb.urls’

STATIC_URL = ‘/static/’

/TFGsWeb/urls.py

from django.contrib import admin
from django.urls import path

Use include() to add paths from the unihub application

from django.urls import include

Add URL maps to redirect the base URL to our application

from django.views.generic import RedirectView

urlpatterns = [
path(‘admin/’, admin.site.urls),
path(‘unihub/’, include(‘unihub.urls’)),
path(‘’, RedirectView.as_view(url=‘/unihub/’, permanent=True)),
]

Use static() to add url mapping to serve static files during development (only)

from django.conf import settings
from django.conf.urls.static import static

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

/TFGsWeb/unihub/urls.py

from django.urls import path
from . import views

urlpatterns = [

]

I don’t understand why this catalog/ appears when I see no reference to any app or path named catalog/ in the files I did modify.

I’d also like to upload this project to my github so should I just do this for the keys or sensible settings info?

with open(‘./secret_key.txt’) as f:
SECRET_KEY = f.read().strip()


#python #django

7 Likes74.90 GEEK