Question:
How to tell Django "if anything in urlpatterns does not match the GET string?

To tell Django "if anything in urlpatterns does not match the GET” string you need to add a catch-all URL pattern that matches anything not previously matched and tries to serve the content from the static files directory.


Here is the code”

# urls.py

from django.conf import settings

from django.views.static import serve

from django.urls import re_path


urlpatterns = [

    re_path(r'^(?P.*)$', serve, {

        'document_root': settings.STATIC_ROOT,

        'show_indexes': False # to avoid listing directories

    }),

    # ...

    # your other patterns

]


Suggested blogs:

>Attempt to read property "data_audit" on array laravel view loop foreach

>How to use start and limit on DataTables in Laravel for mobile API?

>Login to Laravel API- Laravel

>Make Xdebug stop at breakpoints in PhpStorm using Docker

>Creating a service in Laravel using app(FQCN)>How you can Show or hide elements in React?

>Implement nested serializers in the Django rest framework

>Define blade component property in server - Laravel

>Can not run phpstan under docker with memory lack error


Ritu Singh

Ritu Singh

Submit
0 Answers