Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#34585 closed Cleanup/optimization (invalid)

Can we use Class with urlpatterns attribute for parameter in include method?

Reported by: Neeraj Kumar Owned by: nobody
Component: Core (URLs) Version: 4.1
Severity: Normal Keywords: urls
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class ApiV1:
    urlpatterns = (
        path("auth/", include("v1.user.urls")),
        path("doctor/", include("v1.doctor.urls")),
        path("patient/", include("v1.patient.urls")),
    )


class ApiV2:
    urlpatterns = (
        path("auth/", include("v2.user.urls")),
        path("doctor/", include("v2.doctor.urls")),
        path("patient/", include("v2.patient.urls")),
    )


urlpatterns = i18n_patterns(
    path("admin/", admin.site.urls),
    path('api/v1/', include(ApiV1)),
    path('api/v2/', include(ApiV2)),
    prefix_default_language=False,
)

this code is working for me, but in Django docs, nothing mentioned for Class can be used with include method?

So do we need to put restrictions from the Django side for don't use class or otherwise update docs and code to accept Class as an argument in the include method?

Change History (2)

in reply to:  description comment:1 by Mariusz Felisiak, 18 months ago

Resolution: invalid
Status: newclosed

this code is working for me, but in Django docs, nothing mentioned for Class can be used with include method?

So do we need to put restrictions from the Django side for don't use class or otherwise update docs and code to accept Class as an argument in the include method?

I see no reason to document (as officially supported) or restrict this (as officially prohibited).

comment:2 by Mariusz Felisiak, 18 months ago

Type: UncategorizedCleanup/optimization
Note: See TracTickets for help on using tickets.
Back to Top