#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.8cacd774f3bdfc401eb9766c2e664e49%40djangoproject.com.