encode / django-rest-framework

Web APIs for Django. 🎸
https://www.django-rest-framework.org
Other
28.47k stars 6.85k forks source link

restriction for using the word "objects" in API URL #9565

Closed KYPHI-HQ closed 1 month ago

KYPHI-HQ commented 1 month ago

it seems there is a bug or restriction using the word objects in the URL configuration of API as following

Screenshot 2024-10-19 at 06 44 57 Screenshot 2024-10-19 at 06 41 12

updating the code to following: changing the case from objects to Objects will not cause any error longer

Screenshot 2024-10-19 at 06 40 31 Screenshot 2024-10-19 at 06 40 02
tomchristie commented 1 month ago

Seems infeasible. Perhaps try double checking may be some other config issue.

KYPHI-HQ commented 1 month ago

Took the time to reproduce the bug, report it with screenshots ...what is "infeasible" ?

Did you had a look at the screenshots? It's just a case difference ..upper to lowercase

Did you try to use the lowercase word "object" in a URL configuration as shown ?

Did you Try to reproduce it ?

ulgens commented 1 month ago

@KYPHI-HQ Did you try this without DRF? objects is not a keyword afaik I know but its special meaning is assigned at Django layer, not DRF.

KYPHI-HQ commented 1 month ago

I have not tried without DRF (you mean just Django?) since I am developing an API and I have tried following combinations:

not working: DefaultRouter | router.register(r'objects', ObjectViewSet, basename='Object') not working: SimpleRouter | router.register(r'objects', ObjectViewSet, basename='Object') working: DefaultRouter | router.register(r'Objects', ObjectViewSet, basename='Object') working: SimpleRouter | router.register(r'Objects', ObjectViewSet, basename='Object')

there seems to be some issue with the regex combination with lower case word objects

object-list view/api/regex lookup should work......but it is not

api/ ^objects$ [name='object-list']
api/ ^objects\.(?P<format>[a-z0-9]+)/?$ [name='object-list']
api/ ^objects/(?P<pk>[^/.]+)$ [name='object-detail']
api/ ^objects/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$ [name='object-detail']

lowercase objects URL config

Screenshot 2024-10-21 at 07 49 55

Titlecase Objects URL config working

Screenshot 2024-10-21 at 07 55 41
KYPHI-HQ commented 1 month ago

why was this issue closed?

tomchristie commented 1 month ago

Did you Try to reproduce it ?

Nope. It falls into the category of "doesn't pass a sniff test".

Perfectly possible I'm wrong & you're welcome to make a more compelling case here, perhaps isolate the issue yourself.

I don't know you and I don't owe you my time.

browniebroke commented 1 month ago

Did you Try to reproduce it ?

I tried and was unable to reproduce on a minimal Django project: https://github.com/browniebroke/drf-object-viewset

Works perfectly fine:

image

KYPHI-HQ commented 1 month ago

I localized the error, the error occurs when calling the API via Safari browser

the long debug messages gave impression of internal error

no issue when trying to call the API via insomina

Screenshot 2024-10-21 at 17 12 44

or Google Chrome

Screenshot 2024-10-21 at 17 13 14
TGoddessana commented 1 month ago

I don't know if safari browser has secret tabs, but have you tried it? Browsers can also cache internally for things like trailing slashes.