- Read on Monday, March 8, 2010
-
-
SearchableManager
A drop-in chainable manager for providing models with basic search features such as +/- modifiers, quoted exact phrases and ordering by relevance.
Visit
-
SearchableManager
- Read on Wednesday, February 10, 2010
-
-
Get admin url for a model
Add this to your model to be able to get their admin change link from anywhere.
Visit
-
Get admin url for a model
- Read on Tuesday, January 26, 2010
-
-
jQuery Double Click Edit ManyToMany in Admin
Very nice: Put this in your templates/admin/change_form.html template and you will be able to double click a manytomany in a multi select to be able to edit it.
Visit -
Fieldsets for Views
This Snippet allows a view to controle the printed forms on the templates, in a similar way to the fieldsets used by the django admin.
Visit -
Admin Apps Names Translation
This Snippet allows for your project's apps names to be displayed as you want in the Admin, including translations.
Visit
-
jQuery Double Click Edit ManyToMany in Admin
- Read on Sunday, July 5, 2009
-
-
Improved sortby template tag
Variation on dictsort using attribute access. Nested attributes can be used, like, "obj.attr.attr_attr"
Visit
-
Improved sortby template tag
- Read on Thursday, June 18, 2009
-
-
Counter model - run multiple persistent counters
This looks really handy.
Visit
-
Counter model - run multiple persistent counters
- Read on Friday, June 12, 2009
-
-
DRY Fieldsets
A DRY method of declaring django fieldsets, finally! Great Work.
Visit
-
DRY Fieldsets
- Read on Thursday, June 11, 2009
-
-
Custom nose runner
Uses nose test runner, which will discover ALL tests in the application (not just from the tests module of your applications).
Visit -
LoginAsForm - Login as any User without a password
Visit -
manage.py for eclipse with pydev debugging
Showing how to configure Eclipse with PyDev to give you code complete, and breakpoints.
Visit
-
Custom nose runner
- Read on Tuesday, June 2, 2009
-
-
Sometimes Tag
Show part A or part B by chance. Can be useful (replace elements by ads, etc).
Visit
-
Sometimes Tag
- Read on Friday, May 29, 2009
-
-
Custom Cache with SITE_ID in key
Wraps existing cache configured as CUSTOM_CACHE_BACKEND and adds the SITE_ID to cache keys.
Visit
-
Custom Cache with SITE_ID in key
- Read on Wednesday, April 1, 2009
-
-
Django snippets: Smart i18n date diff (twitter like)
This snippet display a human readable date diff. You give it the your date in parameter and the diff with datetime.datetime.now() is returned. The diff must be positive to be more accurate (future dates are not supported). Will give something like: less than 1 minute ago 13 minutes ago 1 hour ago etc.
Visit
-
Django snippets: Smart i18n date diff (twitter like)
- Read on Friday, March 6, 2009
-
-
Smart {% if %} template tag
Save this as smart_if.py in the templatetags folder of one of your apps. Then a simple {% load smartif %} replaces the boring built-in Django {% if %} template with the new smart one.
Visit
-
Smart {% if %} template tag
- Read on Friday, February 27, 2009
-
-
A signal to post new saved objects to Twitter
Post new saved objects to Twitter. (Using string-representative of object an get_abolute_url()-method, which will be tinyurl'zed.)
Visit
-
A signal to post new saved objects to Twitter
- Read on Friday, February 6, 2009
-
-
Ping All Search Engines
Pings the popular search engines, Google, Yahoo, ASK, and Windows Live, to let them know that you have updated your site's sitemap. Returns successfully pinged servers.
Visit
-
Ping All Search Engines
- Read on Tuesday, November 18, 2008
-
-
Use MEDIA_URL in 500 error page
The default server_error view uses Context instead of RequestContext. If you were depending on a context processor to make MEDIA_URL available in your templates, your 500.html template will not render with the correct image paths. This handler adds MEDIA_URL (and nothing else) back to the context that is sent to the template.
Visit
-
Use MEDIA_URL in 500 error page
- Read on Friday, November 7, 2008
-
-
An autocomplete widget for django-tagging form fields
Jannis wrote an often requested feature for django-tagging: Auto complete. This ensures that tags aren't misspelled or anything.
Visit
-
An autocomplete widget for django-tagging form fields
- Read on Monday, October 27, 2008
-
-
ExcelResponse
A subclass of HttpResponse which will transform a QuerySet, or sequence of sequences, into either an Excel spreadsheet or CSV file formatted for Excel, depending on the amount of data. All of this is done in-memory and on-the-fly, with no disk writes, thanks to the cStringIO library.
Visit -
ajax form handler generic view
Some ajax heavy apps require a lot of views that are merely a wrapper around the form. This generic view can be used for them.
Visit
-
ExcelResponse
- Read on Wednesday, October 15, 2008
-
-
send_html_mail
This is quite generic, can auto generate text version of the mail if required.
Visit
-
send_html_mail
- Read on Monday, October 13, 2008
-
-
Django model cron jobs
Inspired by snippet 1126, I thought I would post a module that stores crontab entries in a database, with a less powerful, but more end-user friendly API.
Visit
-
Django model cron jobs
- Read on Friday, October 10, 2008
-
-
Gravatar support for Django comments
A templatetag to add Gravatar support for Django comments.
Visit
-
Gravatar support for Django comments
- Read on Monday, October 6, 2008
-
-
RangeField and RangeWidget
This field and widget is enableing the user to put a start and end value.
Visit -
feedburner middleware
This middleware redirects the request for yoursite.com/feed/whatever/onefeed to your feedburner onefeed feed.
Visit
-
RangeField and RangeWidget
- Read on Friday, September 12, 2008
-
-
WorldIP - access to IP database over API
The WorldIP database provides real-world geographical location. Database is more correct than Whois records and Whois-based databases, that show geographic locations of network owners, and not the geographic location of Internet-connected PC or appliance itself.
Visit -
Retrieve a list of countries from GeoNames
GeoNames provides a useful data file with information about every country in the world (DjangoPeople uses this). Here's an importer that grabs the file from the web and turns it in to a list of dictionaries.
Visit
-
WorldIP - access to IP database over API
- Read on Friday, September 5, 2008
-
-
Django snippets: render_to
Decorator, written for views simplification. Will render dict, returned by view, as context for template, using RequestContext.
Visit
-
Django snippets: render_to
- Read on Tuesday, August 26, 2008
-
-
Django snippets: Login with email or username
A simple backend which allows you to login with either an email address or a username. It should be combined with another backend for checking permissions.
Visit -
models with order (+admin editing)
Use this abstract model if you want to add "order" to a given model. Once you do, you will get automatic "up" and "down" links for each model row.
Visit -
SQL Function Decorator
This decorator will replace a method on a model with a class method that executes SQL in the functions doc string. (Idea of SQL method is great, but the DOC-String solution isn't smart.)
Visit
-
Django snippets: Login with email or username
- Read on Tuesday, August 19, 2008
-
-
Django: Inserting and Positioning Images
Answer of how to associate images and files with your articles, blog posts, etc.
Visit -
Manager method for limiting GenericForeignKey queries
This is a simple manager that offers one additional method called relate, which fetches generic foreign keys (as referenced by content_type and object_id fields) without requiring one additional query for each contained element.
Visit
-
Django: Inserting and Positioning Images
- Read on Friday, August 15, 2008
-
-
ImageFSStorage
A custom FileSystemStorage made for normalizing extensions. It let's PIL look at the file to determine the format and append an always lower-case extension based on the results.
Visit
-
ImageFSStorage
- Read on Tuesday, August 12, 2008
-
-
Expire page from cache
A simple helper function that clears the cache for a given URL, assuming no headers.
Visit -
Readonly admin fields
Visit -
Templatetags to output users online, last registered users, and the last logins.
Visit -
Filter to resize a ImageField on demand
A filter to resize a ImageField on demand.
Visit -
HTML to text filter
This filter converts HTML to nicely-formatted text using the text-browser W3M. Handy for constructing e-mail bodies.
Visit
-
Expire page from cache
- Read on Friday, August 1, 2008
-
-
Update All Apps to Latest Revision
This snippet updates all apps in the current directory using hg, svn, git or bzr. Including subdirectories not under version control (subfolders to keep your stuff organized).
Visit -
Super User Conditional Page Exception Reporting
Normal users will get your 500.html when debug = False, but If you are logged in as a super user then you get to see the stack trace in all its glory.
Visit
-
Update All Apps to Latest Revision
- Read on Monday, July 28, 2008
-
-
Excel Spreadsheet Export
Export data to Excel. Works also with OpenOffice.
Visit
-
Excel Spreadsheet Export
- Read on Tuesday, May 6, 2008
-
-
Auto Logout Middleware
Middleware to logout a user after a certain time. (Defines in ``settings.AUTO_LOGOUT_DELAY``.)
Visit -
AdminPeepingMiddleware
Handy middleware to switch to a different user for one request. Makes debugging very easy.
Visit -
XhtmlDegraderMiddleware
Enables ``application/xhtml+xml`` content-type for browsers, which support it. Others get the usual ``text/html``.
Visit -
Localized URLs (www-en)
Enables language selection based on the URL itself, instead of saving it into a cookie.
Visit
-
Auto Logout Middleware

