Login

Tag "contrib"

Snippet List

Configurable defaults for contrib.sites default Site during syncdb

This simple snippet provides a more sensible default for the Site object created during the first pass of syncdb (that is, with a default domain of `localhost:8000`). I made this so that the admin's "view on site" button will work automagically during my development cycle (which often involves dropping and recreating a sqlite database). In addition, it provides 2 options for configuring the default Site as you'd like: settings parameters (`DEFAULT_SITE_DOMAIN` and `DEFAULT_SITE_NAME`) or `kwargs` (the latter takes precedence).

  • django
  • admin
  • sites
  • syncdb
  • contrib
  • manage
  • Site
  • defaults
Read More

django redirects middleware a bit more fleixble

This is replace for django.contrib.redirects.RedirectFallbackMiddleware which redirects exact matches as well as startswith matches for the redirect.old_path I had a problem with my urls, because are dynamically generic, so I can't create one redirect entry on the database for each possible url. So I made django redirects to search any redirect with the exact match or any database entry being the head of my url, for example: I have django redirects which redirects /calendars/3434/ --> / . But when I have a 404 on /calendars/3434/c/2009/10/23/ now it redirects properly. So my redirects now acts as /calendars/3434/*

  • generic
  • redirects
  • contrib
Read More

2 snippets posted so far.