Error:404 Page not found

Hi All,
This is my first post here, so apologize in advance if I am not providing all the information. But I inherited this project from a different team and trying to run this django project using pycharm and getting 404 Page not found. I have set the Debug to True to see the error and below is what I see on the page

Page not found (404)

Request Method: GET
Request URL: http://127.0.0.1:8000/

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

  1. api/v1/account/
  2. api/v1/authentication/
  3. api/v1/franchises/
  4. api/v1/jurisdictions/
  5. api/v1/registration/
  6. api/v1/reports/
  7. api/v1/schedules/
  8. api/v1/trades/
  9. api/v1/contact-types/
  10. api/v1/inspection-types/
  11. api/v1/documents/
  12. api/v1/dashboards/
  13. api/v1/vocabularies/
  14. api/v1/fees/
  15. api/v1/activities/
  16. api/v1/search/
  17. api/v1/stripe/
  18. api/v1/messages/
  19. api/v1/projects/
  20. api/v1/tickets/
  21. api/v1/project_activities/
  22. api/v1/project_documents/
  23. api/v1/notes/
  24. api/v1/inspections/
  25. api/v1/conditions/
  26. api/v1/form_setup/
  27. site_administrator_panel/
  28. ^user-activation/(?P[-:\w]+)/$ [name=‘account_confirm_email’]
  29. sentry-debug/
  30. api/v1/documentation/ [name=‘schema-redoc’]
  31. ^static/(?P.*)$
  32. ^media/(?P.*)$

The empty path 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.

Below is my projects URL.py code

import re
from django.conf import settings
from django.contrib import admin
# from django.contrib.staticfiles.views import serve
from django.urls import include, re_path
from django.urls import path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from django.conf.urls.static import static
from django.views.generic import TemplateView


urlpatterns = [

    path('api/v1/account/', include('accounts.urls')),
    path('api/v1/authentication/', include('accounts.authentication_urls')),
    path('api/v1/franchises/', include('franchises.urls')),
    path('api/v1/jurisdictions/', include('jurisdictions.urls')),
    path('api/v1/registration/', include('accounts.registration_urls')),
    path('api/v1/reports/', include('reports.urls')),
    path('api/v1/schedules/', include('scheduling.urls')),
    path('api/v1/trades/', include('trades.urls')),
    path('api/v1/contact-types/', include('contact_types.urls')),
    path('api/v1/inspection-types/', include('inspection_types.urls')),
    path('api/v1/documents/', include('documents.urls')),
    path('api/v1/dashboards/', include('dashboards.urls')),
    path('api/v1/vocabularies/', include('vocabularies.urls')),
    path('api/v1/fees/', include('fees.urls')),
    path('api/v1/activities/', include('activities.urls')),
    path('api/v1/search/', include('search.urls')),
    path('api/v1/stripe/', include('stripe_api.urls')),
    path('api/v1/messages/', include('admin_messages.urls')),
    path('api/v1/projects/', include('projects.urls')),
    path('api/v1/tickets/', include('tickets.urls')),
    path('api/v1/project_activities/', include('projects_activities.urls')),
    path('api/v1/project_documents/', include('projects_documents.urls')),
    path('api/v1/notes/', include('notes.urls')),
    path('api/v1/inspections/', include('inspections.urls')),
    path('api/v1/conditions/', include('conditions.urls')),
    path('api/v1/form_setup/', include('form_setup.urls')),
    path('site_administrator_panel/', admin.site.urls),
    re_path(r"^user-activation/(?P<key>[-:\w]+)/$", TemplateView.as_view(), name="account_confirm_email"),

]

# API documentation
schema_view = get_schema_view(
    openapi.Info(
        title='Dashboard API',
        default_version='v1',
        description='Dashboard API',
        terms_of_service='https://www.google.com/policies/terms/',
    ),
    public=True,
    permission_classes=(permissions.AllowAny,),
)


def trigger_error(request):
    division_by_zero = 1 / 0
    assert division_by_zero


urlpatterns += [
    path('sentry-debug/', trigger_error),
    path(
        'api/v1/documentation/',
        schema_view.with_ui('redoc', cache_timeout=0),
        name='schema-redoc',
    ),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I am expecting to see Django login page to login using the superuser. Any advices would be appreciated :wink:

How much of a Django background do you have? Knowing that may help us to more properly target an answer.

The simple and direct answer is that you don’t have an entry in your urlpatterns for an empty url. That’s something for you to provide.

You also need to decide what the behavior of that empty url page is going to be. You say that you want it to be a login page, but do you want that page to appear every time you go to that URL? Even if you’re already logged in?

You may want to review the docs at User authentication in Django | Django documentation | Django and Using the Django authentication system | Django documentation | Django

Thank you for your review. I am a beginner with Django with no experience. I have done some tutorials and learning programs and just getting my hands wet at the moment. Like I said, I inherited this project and would like to run this on my machine for local development and testing. I would just like to make sure that when I do “python manage.py runserver”, it opens a page where I can at least access the admin page or something and not a 404 error.

If you look at your urls, you’ll see that you do have a url defined for the admin system. That’s the url you would use in your browser to access those pages.

Also, I strongly suggest (if you haven’t done so already) to work your way through either (or both) of the Official Django Tutorial and the Django Girls Tutorial. They each cover the essentials that you should learn when starting with Django.

1 Like

Ah, it does work when I go to http://127.0.0.1:8000/site_administrator_panel. I could have sworn I already tried that, but perhaps, I made a type somewhere earlier when I tried. Thank you so much and also I will go through the tutorials you have suggested there. Appreciate your advice!