Snippet List
On a busy site it can be nice to have a summary of admin activity. Running this command (I call it "adminlog") generates output like this:
2009-07-10 18:06:19: pbx changed flat page: "/yay/ -- Let's All Say Yay"
By default it shows the last five actions; pass it a numerical arg to show more or fewer.
Run this as a cron job and you can follow a site's admin-side activity without even logging in!
I work with multiple projects, many of which have multiple custom management commands defined. It can be hard to remember them, and slow to pick them out of the "manage.py help" list.
This quickie command lists all of a project's custom commands (along with their help text). Writing it was easy after looking at the source of django.core.management.
Open questions include: how do you decide which app to put this command in? Should this command list itself?
This is a general-purpose utility function, but since it uses lazy sequences via itertools, so it should be suitable for use with Querysets.
- python
- utility
- sequence
- itertools
Taken from the [longer description on my blog][1]:
> One of the great things about Django is its simple and flexible URL handling. If your Django work, like mine, includes converting existing sites, you’ll probably be doing some URL cleanup along the way...
Just plug your old/new URL pairs into `redirects`.
[1]: http://e-scribe.com/news/290
I use these helper methods in my unit tests. They turn many simple getting-and-posting tests into one-liners. Definitely a work in progress, and I can't be the only person who has done this sort of thing -- comments are more than welcome.
Described more fully on [my blog](http://e-scribe.com/news/230), but the gist is: this model becomes a sort of mini-app in your admin, allowing you to record and track issues related to your other applications.
Sorting still needs some work.
UPDATED 2007-03-14: Fixed repeat in Admin.list_display (thanks, burly!); added Admin.list_filter; changed app list (why did I call that `PROJECTS`, anyway?) to omit "django.*" apps
pbx has posted 10 snippets.