[Django] #32989: my urls, views, and templates work, but view_on_site in the admin does not.

4 views
Skip to first unread message

Django

unread,
Aug 4, 2021, 6:01:22 PM8/4/21
to django-...@googlegroups.com
#32989: my urls, views, and templates work, but view_on_site in the admin does not.
-----------------------------------------+------------------------
Reporter: Malik A. Rumi | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I have a problem with view_on_site in the admin. I screwed up my app
templates, and when I figured
out the problem and got them all fixed, I discovered that view_on_site was
giving me the same
errors I had with my templates. But I have not been able to fix
view_on_site.

I have two theories:

1. I have not been able to determine what template it is using (debug
toolbar says None) or how
it decides what template to use. It doesn't seem to work like the CBV.
If I had that info,
perhaps I could point it to my actual, working template.

2. since get_absolute_url returns a leading '/', that screws up the
call because my urls.py
ends in a '/', which is how we are supposed to do it.

Compare:
https://docs.djangoproject.com/en/3.1/ref/contrib/sites/#getting-the-
current-domain-for-full-urls
and
https://code.djangoproject.com/ticket/27757#comment:5
with
https://docs.djangoproject.com/en/3.1/topics/http/urls/#example

Thus view_on_site is actually calling
"mysite.com/ktab/entry//admin/r/7/3509/" or
"mysite.com/ktab/entry//half-hercules/", and the extra slash - what
you call a 'prefix',
I think, is messing it up.

The error I am getting is:
NoReverseMatch at /admin/r/7/3509/
Reverse for 'EntryDetail_url' with keyword arguments
'{'app_label': 'ktab', 'slug': 'half-hercules'}' not found. 1
pattern(s) tried:
['ktab/entry/(?P<slug>[-a-zA-Z0-9_]+)/$']

This is right and should work, just as it works with my url, view, and
template, but since
view_on_site isn't really using those kwargs, I assume that is at least
part of the problem.
But since the content type and object id are correct, I don't know where
to go from here.

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

Django

unread,
Aug 4, 2021, 6:36:36 PM8/4/21
to django-...@googlegroups.com
#32989: my urls, views, and templates work, but view_on_site in the admin does not.
-------------------------------+--------------------------------------

Reporter: Malik A. Rumi | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 3.1
Severity: Normal | Resolution: invalid

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

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


Comment:

Hi, Please see TicketClosingReasons/UseSupportChannels for ways to get
help. If you confirm a bug in Django, feel free to reopen with an
explanation of why Django is at fault. Thanks!

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

Reply all
Reply to author
Forward
0 new messages