Opened 8 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 , 8 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 8 years ago
Component: | Uncategorized → contrib.flatpages |
---|
comment:3 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 8 years ago
Resolution: | → needsinfo |
---|---|
Status: | assigned → closed |
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 , 8 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
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.
comment:6 by , 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: | Unreviewed → Accepted |
comment:7 by , 7 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
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.
Can you show me your urls.py file?