Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7257 closed (duplicate)

Flatpage view returns 404 unless url contains trailing slash

Reported by: sean Owned by:
Component: Contrib apps Version: master
Severity: Keywords: flatpages
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The admin interface for flatpages instructs user to use a trailing slash for the flatpage url. However, if an attempt to access the flatpage without the trailing slash is made, a 404 error is returned instead of the flatpage.

Attachments (2)

flatpage_view.diff (411 bytes) - added by sean 6 years ago.
flatpages.patch (955 bytes) - added by crankycoder@… 6 years ago.
flatpages patch to force redirects if APPEND_SLASH is enabled in settings.py

Download all attachments as: .zip

Change History (13)

comment:1 Changed 6 years ago by sean

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

Changed 6 years ago by sean

comment:2 Changed 6 years ago by sean

  • Has patch set

comment:3 Changed 6 years ago by ubernostrum

  • Resolution set to worksforme
  • Status changed from assigned to closed

Feels like you want to turn on CommonMiddleware and APPEND_SLASH, which are both on by default.

comment:4 Changed 6 years ago by crankycoder@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened

This doesn't work in django trunk (r7877) and I have CommonMiddleware and APPEND_SLASH=True.

This seems to be because of the way CommonMiddleware detects if a URL already exists - it looks up URLs in urlresolvers.

As FlatPages doesn't talk to urlresolvers - no page in FlatPages will ever resolve.

The attached patch (flatpages.patch) forces a redirect since I don't like the idea of automatically adding new URLs that will respond to requests.

Changed 6 years ago by crankycoder@…

flatpages patch to force redirects if APPEND_SLASH is enabled in settings.py

comment:5 Changed 6 years ago by anonymous

  • milestone set to 1.0 beta

comment:6 Changed 6 years ago by shawnr

  • Owner changed from anonymous to shawnr
  • Status changed from reopened to new

comment:7 Changed 6 years ago by shawnr

  • Triage Stage changed from Unreviewed to Ready for checkin

Malcolm looked over my shoulder and we walked through some tests. It seems to behave properly, so this patch looks good.

comment:8 Changed 6 years ago by shawnr

  • Owner shawnr deleted

comment:9 Changed 6 years ago by anonymous

looks like a duplicate of #6213...

comment:10 Changed 6 years ago by anonymous

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

comment:11 Changed 3 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

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.