Opened 3 years ago

Closed 3 years ago

#32989 closed Uncategorized (invalid)

my urls, views, and templates work, but view_on_site in the admin does not.

Reported by: Malik A. Rumi Owned by: nobody
Component: Uncategorized Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.
  1. 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/entryadmin/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/(

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.

Change History (1)

comment:1 by Tim Graham, 3 years ago

Resolution: invalid
Status: newclosed

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!

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