[Django] #34585: Can we use Class with urlpatterns attribute for parameter in include method?

4 views
Skip to first unread message

Django

unread,
May 21, 2023, 6:06:54 AM5/21/23
to django-...@googlegroups.com
#34585: Can we use Class with urlpatterns attribute for parameter in include
method?
-----------------------------------------+------------------------
Reporter: Neeraj Kumar | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (URLs) | Version: 4.1
Severity: Normal | Keywords: urls
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
{{{
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?

--
Ticket URL: <https://code.djangoproject.com/ticket/34585>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 21, 2023, 6:51:03 AM5/21/23
to django-...@googlegroups.com
#34585: Can we use Class with urlpatterns attribute for parameter in include
method?
-------------------------------+--------------------------------------

Reporter: Neeraj Kumar | Owner: nobody
Type: Uncategorized | Status: closed

Component: Core (URLs) | Version: 4.1
Severity: Normal | Resolution: invalid

Keywords: urls | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

> 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).

--
Ticket URL: <https://code.djangoproject.com/ticket/34585#comment:1>

Django

unread,
May 21, 2023, 6:51:16 AM5/21/23
to django-...@googlegroups.com
#34585: Can we use Class with urlpatterns attribute for parameter in include
method?
-------------------------------------+-------------------------------------

Reporter: Neeraj Kumar | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: Core (URLs) | Version: 4.1
Severity: Normal | Resolution: invalid
Keywords: urls | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* type: Uncategorized => Cleanup/optimization


--
Ticket URL: <https://code.djangoproject.com/ticket/34585#comment:2>

Reply all
Reply to author
Forward
0 new messages