Opened 7 years ago

Closed 7 years ago

#28118 closed Bug (duplicate)

reverse() and get_absolute_url() may return different output for same FlatPage

Reported by: Pat Owned by: Michal
Component: contrib.flatpages Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

>>>
>>> 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.

Change History (7)

comment:1 by Pat, 7 years ago

Type: UncategorizedBug

comment:2 by Pat, 7 years ago

Component: Uncategorizedcontrib.flatpages

comment:3 by Michal, 7 years ago

Owner: changed from nobody to Michal
Status: newassigned

Can you show me your urls.py file?

comment:4 by Michal, 7 years ago

Resolution: needsinfo
Status: assignedclosed

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.

comment:5 by Tim Graham, 7 years ago

Resolution: needsinfo
Status: closednew

Closing a ticket as "needsinfo" means the reporter hasn't provided enough information (see Closing Tickets). Without some investigation, I'm also not sure how to proceed here however closing the ticket because of that isn't correct.

If a code change isn't practical, we might document the reasons for this.

Last edited 7 years ago by Tim Graham (previous) (diff)

comment:6 by Tim Graham, 7 years ago

Summary: reverse() and get_absolute_url() returns different output for same object ?reverse() and get_absolute_url() may return different output for same FlatPage
Triage Stage: UnreviewedAccepted

comment:7 by Mark Lavin, 7 years ago

Resolution: duplicate
Status: newclosed

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.

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