Code

Opened 3 years ago

Closed 20 months ago

Last modified 20 months ago

#14556 closed Cleanup/optimization (fixed)

Recommend to avoid FlatpageFallbackMiddleware unless absolutely required

Reported by: patrys Owned by: nobody
Component: Documentation Version: 1.2
Severity: Normal Keywords: flatpages
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

In most cases you don't need conflicting routing rules in urls.py so it's easier to just include('django.contrib.flatpages.urls'). As a free bonus you get to avoid all kinds of problems with other middleware, contextprocessors and the CSRF framework.

I can see how the middleware is useful if for some reason you have to put the flat pages in the same URL prefix another application uses but it's a workaround that breaks the documented routing behavior. I for one don't expect apps to provide their own url routing middleware instead of urls.py and I can't see how flatpages is an exception here.

Attachments (1)

14556-1.diff (2.0 KB) - added by claudep 2 years ago.
Draft of possible flatpages docs complement

Download all attachments as: .zip

Change History (6)

comment:1 Changed 3 years ago by gabrielhurley

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

More importantly, using the FlatPages URLconf isn't even mentioned as an option in the docs. However, it should be noted that the FlatPages URLConf has to come last in your patterns, because it will match *anything* and pre-empt any patterns after it.

Both use cases (middleware and URLConf) are valid, and I'm not convinced that preference should be given to one or the other. At the very least they should be documented equally, though.

comment:2 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to Cleanup/optimization

Changed 2 years ago by claudep

Draft of possible flatpages docs complement

comment:3 Changed 2 years ago by claudep

  • Easy pickings unset
  • Has patch set
  • Patch needs improvement set
  • UI/UX unset

Very basic draft (Formatting not tested, language to check, etc.)

comment:4 Changed 20 months ago by Tim Graham <timograham@…>

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

In [7235cc76859ba63b3eba3e91abd74aa8dd66c8c9]:

Fixed #14556 - Documented how to use flatpages in URLconf; thanks Claude Paroz for the draft patch.

comment:5 Changed 20 months ago by Tim Graham <timograham@…>

In [df0c1055cd09eed24ba56efa7df206512e4aa96c]:

[1.4.X] Fixed #14556 - Documented how to use flatpages in URLconf; thanks Claude Paroz for the draft patch.

Backport of 7235cc7685 from master

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.