Django tried these URL patterns

463 views
Skip to first unread message

Mike Kilmer

unread,
Jun 17, 2022, 6:45:19 PM6/17/22
to Django users
This app is set up to create webhooks and receive requests, however the routing has broken and the requests are getting a 404.

The path looks like this:


The Stack Track/Routing:

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

  1. baton/
  2. [name='index']
  3. etc...
  4. integrations/request/
  5. reports/clientreport/
  6. ^(?P<app_label>auth|sites|account|socialaccount|users|core|integrations|reports)/$ [name='app_list']
  7. (?P<url>.*)$

The current path, integrations/dc3509ac-1aa8-4c9a-a439-904342d885cd/order, matched the last one.

My URL setup is like this:

urlpatterns = [
    path("baton/", include("baton.urls")),
    # Be sure "baton/" is at the beginning of the list, before "".
    path("", admin.site.urls),
    path('accounts/', include('allauth.urls')),
    path("integrations/", include("integrations.urls")),
    path("queryfilter/", include("core.urls")),
    path("docs/", include("docs.urls")),
    path(
        "favicon.ico", RedirectView.as_view(url=staticfiles_storage.url("favicon.ico"))
    ),
]

With integrations.urls like this:

urlpatterns = [
  path(
    "<uuid:integration_uuid>/order",
      incoming_order,
      name="incoming-order",
    ),
]


The incoming_order method looks like this:

@csrf_exempt
@require_http_methods(["POST"])
def incoming_order(request, integration_uuid):
    headers = request.headers
    request_body = request.body.decode("utf-8")
    log = Request.objects.create(
        url=request.build_absolute_uri(), body=request_body, headers=dict(headers)
    )

    log.process(integration_uuid)

    return JsonResponse({"status": "ok"})

Any suggestions?

Mike Kilmer

unread,
Jun 17, 2022, 8:22:19 PM6/17/22
to Django users
Not sure why, but moving path("integrations/", include("integrations.urls")), above the "" slash seems to have solved the problem.
Reply all
Reply to author
Forward
0 new messages