A Django Theoritical discussion point. Re-post from Webfaction forum -
more a django question than webfaction specific).
Over the weekend I had a huge number of pages/hits from one IP address
(logged via awstats). Assuming some kind of funny business I decided
to block that IP address. Two approaches:-
Redirect App as per this -
http://forum.webfaction.com/viewtopic.php?id=1516
or this snippet here -
http://djangosnippets.org/snippets/744/
The Redirect Static App which does nothing except provide access to
the Django site via a route which allows htaccess is a popular
solution mainly for !www to www solutions, and in my case to make
available 'deny 123.123.123.123'.
Given that !www to www or vice versa is commonly required and other
capabilities of htaccess may be useful (e.g. deny) is there a case for
arguing that all Django Apps should be accessed via a Static App? Only
downside being that another operation is required which will take up
some time and resources (potentially negligible).
But one feature I like about Django is that I don't have to deal with
the dreaded complexity of htaccess for tasks like redirects such as -
urlpatterns += patterns('django.views.generic.simple', ('^index.php/
$', 'redirect_to', {'url': '/'}),
(I've got loads of these for the site in question due to a
migration).
So maybe Django should be handling !www to www and deny etc (hence
snippet 744 may be useful)? Thus dropping completely the need for the
Static/htaccess approach.
Summary - either use Static/htaccess with every Django site or find a
way to do all/most htaccess stuff in Django. Any views.