Opened 11 years ago
Last modified 5 years ago
#22261 closed Bug
reverse() and get_absolute_url() may return different values for same FlatPage — at Version 6
Reported by: | Owned by: | edanm | |
---|---|---|---|
Component: | contrib.flatpages | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | edanm | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The FlatPage model implements get_absolute_url()
without using reverse()
. The comment suggests, that this handles SCRIPT_NAME
issues, but the link in the admin interface does not work, if you are using a prefix for the flatpages urls. The templatetag for resolving a flatpage works just fine.
Change History (6)
comment:1 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 11 years ago
Has patch: | set |
---|
I just sent a pull request for a fix for this:
https://github.com/django/django/pull/2554
This solves all the cases I can think of for including flatpages and running get_absolute_url() on them.
By the way, not sure if this is relevant, but:
When I was writing the tests for this, I noticed that all the flatpages tests include the flatpages url without a slash, e.g.:
url(r'flatpage_root', include('django.contrib.flatpages.urls')), (Note lack of '/' after flatpage_root).
This is different than how the documentation recommends including the flatpages, and doesn't make much sense. Not sure what the purpose of this is.
comment:4 by , 11 years ago
Cc: | added |
---|
comment:5 by , 10 years ago
Patch needs improvement: | set |
---|
I left comments for improvement on the PR. Please uncheck "Patch needs improvement" when you update it, thanks.
comment:6 by , 7 years ago
Description: | modified (diff) |
---|---|
Summary: | Wrong Permalink for flatpages → reverse() and get_absolute_url() may return different values for same FlatPage |
#28118 is a duplicate.
The implementation is intended to match the catchall middleware.
We could try reversing and only if that fails fall back to the current logic.