Opened 2 years ago

Closed 23 months ago

Last modified 23 months ago

#34286 closed Bug (fixed)

Mixed-case views/templates names causes 404 on :view:/:template: directive.

Reported by: Alex Life Owned by: Rahmat Faisal
Component: contrib.admindocs Version: 4.1
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://github.com/django/django/blob/main/django/contrib/admindocs/views.py#L168

Using a class based view,
class OrderSearch(LoginRequiredMixin, UserPassesTestMixin, ListView):

add a doc comment such as
:view:orders.views.Orders

causes a 404 when you click on the link in the docs

Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/admin/doc/views/orders.views.orders/
Raised by: django.contrib.admindocs.views.ViewDetailView

I'm not sure exactly where orders becomes lowercase, but I thought it might have something to do with the _get_view_func

Change History (11)

comment:1 by Mariusz Felisiak, 2 years ago

Summary: Class based views cause 404 on admindocs.views.ViewDetailViewClass based views cause 404 on :view: directive.
Triage Stage: UnreviewedAccepted

Thanks for the ticket. It was originally reported in the #27409 among other issues

"For views you can use generic class based views, in there by naming conventions can be capital letters. Class based views are classes and not methods and the naming of the view can be like BlogView or BlogEdit. But if generating link using the directives according to documentation it will not work since it will try to find view by name of blogview instead of BlogView. It will automatically put it to lowercase and may make it not working."

but I think it deserves a separate ticket.

comment:2 by Rahmat Faisal, 2 years ago

Owner: changed from nobody to Rahmat Faisal
Status: newassigned

gonna look

in reply to:  2 comment:3 by Rahmat Faisal, 23 months ago

Replying to Rahmat Faisal:

gonna look

Yeah if u have views for example

class About(Views):
...

and in the docs you write

:view:`app_label.views.About`

and if u acces, and the url gonna change to localhost:8000/admin/docs/app_label.views.about and return 404. the url should be localhost:8000/admin/docs/app_label.views.About

Last edited 23 months ago by Rahmat Faisal (previous) (diff)

comment:4 by Rahmat Faisal, 23 months ago

the problem from admindocs utils function https://github.com/django/django/blob/main/django/contrib/admindocs/utils.py#L59, that makes convert into lowercase

Version 0, edited 23 months ago by Rahmat Faisal (next)

comment:5 by Rahmat Faisal, 23 months ago

Has patch: set

comment:6 by Mariusz Felisiak, 23 months ago

Needs tests: set

comment:7 by Rahmat Faisal, 23 months ago

add simple test case for :view:

comment:8 by Mariusz Felisiak, 23 months ago

Patch needs improvement: set
Summary: Class based views cause 404 on :view: directive.Mixed-case views/templates names causes 404 on :view:/:template: directive.

comment:9 by Mariusz Felisiak, 23 months ago

Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 23 months ago

Resolution: fixed
Status: assignedclosed

In 1250483:

Fixed #34286 -- Fixed admindocs markups for case-sensitive template/view names.

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 23 months ago

In db0e10c:

[4.2.x] Fixed #34286 -- Fixed admindocs markups for case-sensitive template/view names.

Backport of 1250483ebf73f7a82ff820b94092c63ce4238264 from main

Note: See TracTickets for help on using tickets.
Back to Top