Opened 2 years ago

Last modified 2 years ago

#22261 assigned Bug

Wrong Permalink for flatpages

Reported by: allo@… 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: yes
Easy pickings: no UI/UX: no


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 (5)

comment:1 Changed 2 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

The implementation is intended to match the catchall middleware.

We could try reversing and only if that fails fall back to the current logic.

comment:2 Changed 2 years ago by edanm

  • Owner changed from nobody to edanm
  • Status changed from new to assigned

comment:3 Changed 2 years ago by edanm

  • Has patch set

I just sent a pull request for a fix for this:

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.

Last edited 2 years ago by edanm (previous) (diff)

comment:4 Changed 2 years ago by edanm

  • Cc edanm added

comment:5 Changed 2 years ago by timgraham

  • Patch needs improvement set

I left comments for improvement on the PR. Please uncheck "Patch needs improvement" when you update it, thanks.

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