Code

#18862 closed Cleanup/optimization (fixed)

FlatPages get_absolute_url should pay attention to script prefix

Reported by: GunnarScherf Owned by: nobody
Component: contrib.flatpages Version: 1.4
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

When hosting a django app under a subpath of a domain, then get_absolute_url returns the url without the subpath.

    def get_absolute_url(self):
        return self.url

Better would be if the subpath is recognized

    def get_absolute_url(self):
        absolute_url = "%s%s" % (get_script_prefix().rstrip('/'), self.url)
        return absolute_url

Attachments (0)

Change History (4)

comment:1 Changed 22 months ago by thejaswi_puthraya

  • Component changed from Uncategorized to contrib.flatpages
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 21 months ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 17 months ago by aaugustin

Yes, this is necessary because flatpages bypass the URL resolver (and specifically the reverse function) entirely.

comment:4 Changed 17 months ago by Aymeric Augustin <aymeric.augustin@…>

  • Resolution set to fixed
  • Status changed from new to closed

In a44531ae1592cf266e6c24387f49d665c639b480:

Fixed #18862 -- Honored script prefix in FlatPage.get_absolute_url.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.