Issues with AdminSite and customing it's urlspattern

So my problem is i can not custom default url patterns and expand it with my own urls:

in malex_admin.admin

class MalexAdminSite(admin.AdminSite):
    site_header = "Malex"

    def get_urls(self):
        urls_patterns = super().get_urls()
        new_patterns = [
            path("orders", include("orders.urls"))
        ]

        return urls_patterns + new_patterns

In orders.urls

from django.urls import path
from . import views

urlpatterns = [
    path("", views.orders)
]

In settings

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'malex_admin.apps.MalexAdminConfig',
    'orders.apps.OrdersConfig'
]

Everything is fine with installation of my own admin site, but i really don’t understand why after trying to get page under url path “admin/orders” it responds with error 404 and what is intersting, that in list of urls there is no modification. You can see it on screenshot:

Please help me, because i didn’t find any information in the Internet. Thanks

  1. You need to make sure that you are adding your custom URLs before the default admin URLs:
def get_urls(self):
    urls_patterns = super().get_urls()
    new_patterns = [
        path("orders/", include("orders.urls"))
    ]
    return new_patterns + urls_patterns  # Custom patterns first
  1. Add a trailing slash to the “orders” path:
path("orders/", include("orders.urls"))
  1. Post your malex_admin/apps.py code. You need to ensure your MalexAdminConfig is set up to use your custom admin site:
from django.contrib.admin.apps import AdminConfig

class MalexAdminConfig(AdminConfig):
    default_site = 'malex_admin.admin.MalexAdminSite'

Thank you a lot, really. There was only one problem on this stage:

return new_patterns + urls_patterns  # Custom patterns first

I forgot to mention that i have this part of code already:

from django.contrib.admin.apps import AdminConfig

class MalexAdminConfig(AdminConfig):
    default_site = 'malex_admin.admin.MalexAdminSite'

So there is only one difference between yours an my code that i mentioned above, thank you a lot!!!

Glad it worked for you!