Login

Snippets by muhuk

Snippet List

Fix duplicate first page of paginated results

Search engines might conclude there's duplicate content if `/some_view/` and `/some_view/?page=1` returns the same results. This middleware redirects `?page=1` to the URL without the page parameter. You can set the name of the parameter in settings.py as `PAGE_VAR`. See [here](http://www.muhuk.com/2009/08/a-civilized-way-display-lots-of-data/) for more details.

  • middleware
  • pagination
  • seo
  • paginate
Read More

Generic Permissions

A mixin to define permissions on models. This is more of an abstract model to subclass/customise than a plug-in solution. Explanations are [here](http://www.muhuk.com/2009/05/django-permission-system/).

  • models
  • model
  • permission
  • authorization
Read More

nofollow filter for external links

Based on [svetlyak](http://www.djangosnippets.org/users/svetlyak/)'s [nofollow filter](http://www.djangosnippets.org/snippets/312/). This one processes only external URL's. Links with internal URL's will be returned unmodified. There's one gotcha; I preferred to have false positives instead of false negatives. So, it will nofollow `href="some/relative/path/"` for example. If you must do relative paths do it like this: <a href="./some/relative/path">link text</a>

  • filter
  • nofollow
Read More

muhuk has posted 3 snippets.