Opened 14 years ago

Closed 12 years ago

Last modified 12 years ago

#14556 closed Cleanup/optimization (fixed)

Recommend to avoid FlatpageFallbackMiddleware unless absolutely required

Reported by: Patryk Zawadzki 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 Claude Paroz 13 years ago.
Draft of possible flatpages docs complement

Download all attachments as: .zip

Change History (6)

comment:1 by Gabriel Hurley, 14 years ago

Keywords: flatpages added
Triage Stage: UnreviewedAccepted

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 by Julien Phalip, 13 years ago

Severity: Normal
Type: Cleanup/optimization

by Claude Paroz, 13 years ago

Attachment: 14556-1.diff added

Draft of possible flatpages docs complement

comment:3 by Claude Paroz, 13 years ago

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 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [7235cc76859ba63b3eba3e91abd74aa8dd66c8c9]:

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

comment:5 by Tim Graham <timograham@…>, 12 years ago

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

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