Login

All snippets

Snippet List

User groups template tag

This snippet is an improved version of the [ifusergroup](http://djangosnippets.org/snippets/1576/) tag that allows spaces in any of the group names. It also fixes a small bug where if a group didn't exist none of the subsequent groups would be checked.

  • tag
  • templatetag
  • user
  • auth
  • group
  • permissions
  • access-control
Read More

Admin related widget wrapper with edit / delete link (python model admin)

Here's the python code to produce an admin related widget with the edit and delete link also. * [RelatedFieldWidgetWrapper](http://djangosnippets.org/snippets/2562) * [related-widget-wrapper.html](http://djangosnippets.org/snippets/2563) * [related-widget-wrapper.js](http://djangosnippets.org/snippets/2564) * [RelatedWidgetWrapperAdmin](http://djangosnippets.org/snippets/2565)

  • admin
  • related
  • widget
  • wrapper
Read More

Admin related widget wrapper with edit / delete link (widget js)

Here's the python code to produce an admin related widget with the edit and delete link also. * [RelatedFieldWidgetWrapper](http://djangosnippets.org/snippets/2562) * [related-widget-wrapper.html](http://djangosnippets.org/snippets/2563) * [related-widget-wrapper.js](http://djangosnippets.org/snippets/2564) * [RelatedWidgetWrapperAdmin](http://djangosnippets.org/snippets/2565)

  • admin
  • related
  • widget
  • wrapper
Read More

Admin related widget wrapper with edit / delete link (html)

Here's the python code to produce an admin related widget with the edit and delete link also. * [RelatedFieldWidgetWrapper](http://djangosnippets.org/snippets/2562) * [related-widget-wrapper.html](http://djangosnippets.org/snippets/2563) * [related-widget-wrapper.js](http://djangosnippets.org/snippets/2564) * [RelatedWidgetWrapperAdmin](http://djangosnippets.org/snippets/2565)

  • admin
  • related
  • widget
  • wrapper
Read More

Admin related widget wrapper with edit / delete link (python widget)

Here's the python code to produce an admin related widget with the edit and delete link also. * [RelatedFieldWidgetWrapper](http://djangosnippets.org/snippets/2562) * [related-widget-wrapper.html](http://djangosnippets.org/snippets/2563) * [related-widget-wrapper.js](http://djangosnippets.org/snippets/2564) * [RelatedWidgetWrapperAdmin](http://djangosnippets.org/snippets/2565)

  • admin
  • related
  • widget
  • wrapper
Read More

easy signal registration

Django signals can live anywhere you like. I like them in *app/signals.py* file. This snippet imports signal modules from all installed apps.

  • registration
  • signal
Read More

Send templated email with text | html | optional files

Use this to send emails to your users, takes one template and renders it as html or text as needed. Credits to """ Jutda Helpdesk - A Django powered ticket tracker for small enterprise. (c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. lib.py - Common functions (eg multipart e-mail) """ MIT licence I only removed the specific project parts and made it general to use. The original project repository https://github.com/rossp/django-helpdesk/

  • template
  • email
  • function
Read More

Generic admin action export selected rows to excel

Based on [http://djangosnippets.org/snippets/1697/](http://djangosnippets.org/snippets/1697/) but improved with multiline fields, and unicode chars. Also it generates an xls file, not a csv one. Requires, pyExcelerator *Usage:* Add the code to your project, e.g. a file called actions.py in the project root. Register the action in your apps admin.py: from myproject.actions import export_as_xls class MyAdmin(admin.ModelAdmin): actions = [export_as_xls]

  • export
  • admin-actions
  • xls
Read More

django-pagination with "clean url"

To enable "clean url" mode, install [django-pagination](http://code.google.com/p/django-pagination/), then just add to settings.py PAGINATION_CLEAN_URL = True and replace '.../pagination/templatetags/pagination_tags.py' with follow, and so add to 'pagination/templates/pagination/' folder pagination_clean_url.html file, with following code **Note:** in urls.py should be like this: url(r'^/foo/bar/\d*/?$', foobar_list_handle),

  • pagination
  • clean url
Read More

3110 snippets posted so far.