[Django] #28118: reverse() and get_absolute_url() returns different output for same object ?

15 views
Skip to first unread message

Django

unread,
Apr 24, 2017, 2:12:13 AM4/24/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() returns different output for same object ?
-----------------------------------------+------------------------
Reporter: Pat | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
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 |
-----------------------------------------+------------------------
{{{
>>>
>>> from django.contrib.flatpages.models import FlatPage
>>>
>>> about = FlatPage.objects.get(id=1)
>>>
>>> about
<FlatPage: /about/ -- About>
>>>
>>> about.url
'/about/'
>>>
>>> about.get_absolute_url()
'/about/'
>>>
>>> from django.core.urlresolvers import reverse
>>>
>>> reverse("django.contrib.flatpages.views.flatpage", args=[about.url])
'/page/about/'
>>>
}}}

Why reverse() and get_absolute_url() returns two different output and what
the purpose behind it ?

I have tested this code in Django 1.8 and 1.10, the same behavior
persists.

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

Django

unread,
Apr 24, 2017, 2:12:59 AM4/24/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() returns different output for same object ?
-------------------------------+--------------------------------------
Reporter: Pat | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Resolution:

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 Pat):

* type: Uncategorized => Bug


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

Django

unread,
Apr 24, 2017, 2:13:50 AM4/24/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() returns different output for same object ?
-----------------------------------+--------------------------------------
Reporter: Pat | Owner: nobody
Type: Bug | Status: new
Component: contrib.flatpages | Version: 1.8
Severity: Normal | Resolution:

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 Pat):

* component: Uncategorized => contrib.flatpages


--
Ticket URL: <https://code.djangoproject.com/ticket/28118#comment:2>

Django

unread,
Apr 25, 2017, 11:50:48 AM4/25/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() returns different output for same object ?
-----------------------------------+--------------------------------------
Reporter: Pat | Owner: Michal
Type: Bug | Status: assigned

Component: contrib.flatpages | Version: 1.8
Severity: Normal | Resolution:
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 Michal):

* status: new => assigned
* owner: nobody => Michal


Comment:

Can you show me your urls.py file?

--
Ticket URL: <https://code.djangoproject.com/ticket/28118#comment:3>

Django

unread,
Apr 26, 2017, 7:06:02 AM4/26/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() returns different output for same object ?
-----------------------------------+--------------------------------------
Reporter: Pat | Owner: Michal
Type: Bug | Status: closed
Component: contrib.flatpages | Version: 1.8
Severity: Normal | Resolution: needsinfo

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 Michal):

* status: assigned => closed
* resolution: => needsinfo


Comment:

I am not sure why flatpages in get_absolute_url are not using "reverse" to
get full url address.

I could replace that, add tests - but I need some info if there is some
reason to leave it as is.

--
Ticket URL: <https://code.djangoproject.com/ticket/28118#comment:4>

Django

unread,
Apr 26, 2017, 8:30:08 AM4/26/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() returns different output for same object ?
-----------------------------------+--------------------------------------
Reporter: Pat | Owner: Michal
Type: Bug | Status: new

Component: contrib.flatpages | Version: 1.8
Severity: Normal | Resolution:
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: closed => new
* resolution: needsinfo =>


Comment:

Closing a ticket as "needsinfo" means the reporter hasn't provided enough
information (see
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#closing-tickets Closing Tickets]). Without some investigation,
I'm also not sure how to proceed here however closing the ticket because
of that isn't correct.

--
Ticket URL: <https://code.djangoproject.com/ticket/28118#comment:5>

Django

unread,
May 18, 2017, 11:11:30 AM5/18/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() may return different output for same
FlatPage
-----------------------------------+------------------------------------

Reporter: Pat | Owner: Michal
Type: Bug | Status: new
Component: contrib.flatpages | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28118#comment:6>

Django

unread,
Aug 17, 2017, 12:54:20 PM8/17/17
to django-...@googlegroups.com
#28118: reverse() and get_absolute_url() may return different output for same
FlatPage
-----------------------------------+-------------------------------------
Reporter: Pat | Owner: Michal
Type: Bug | Status: closed
Component: contrib.flatpages | Version: 1.8
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+-------------------------------------
Changes (by Mark Lavin):

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


Comment:

From what I can tell this is a duplicate of #22261 which was discussed a
few years ago. The resolution was that it seemed reasonable to change to
use {{{reverse}}} for {{{get_absolute_url}}}. A PR
https://github.com/django/django/pull/2554 was submitted but never updated
after an initial review. If you are looking to move this forward then
starting from that PR branch and updating it would be a good start.

--
Ticket URL: <https://code.djangoproject.com/ticket/28118#comment:7>

Reply all
Reply to author
Forward
0 new messages