Pissed-off Command Prompt
Computers need to vent their frustration sometimes, too!
- profanity
Computers need to vent their frustration sometimes, too!
Add-on for auth app of newforms-admin branch, adding more information about users and their groups at user and group list in admin interface. Also, nice example on customization of contributed django admin apps. It adds the following to the user list interface: fields for is_superuser and is_staff, last login time; by default, short names of groups user is in (mousehover to see full names) It adds the following to the to group list interface: list of users in your groups. To enable, just put it somewhere and import it from your main urls.py: import useradmin
This tag allow you to use C-like switch tag in your templates. It is useful for sequencial and repetitive `{% ifequal %}` tags. To install it in your project, you just need to follow [these instructions](http://www.djangoproject.com/documentation/templates_python/#extending-the-template-system)
While we're on the topic of SSLRedirect (See snippet 240 and 880) here's what I add to the end of my ssl middleware module, so that SSLRedirect wont break my automated testing. It simply creates a dummy middleware class that removes the SSL argument, but does not do any redirecting. If you were to simply remove the middleware from settings, the extra SSL argument will then get passed on to all the relevant views. Of course, you'll need to define a TESTING variable in settings, or change this to something else like settings.DEBUG. Having the separate variable for testing allows you to run your server in DEBUG mode without side effects like the change above.
This is a ModelForms-based rewrite of the create_object and update_object generic views, with a few added features. The views now accept a "form_class" argument optionally in place of the "model" argument, so you can create and tweak your own ModelForm to pass in. They also accept a "pre_save" callback that can make any additional changes to the created or updated instance (based on request.user, for instance) before it is saved to the DB. Usage: just save the code in a file anywhere on the PythonPath and use the create_object and update_object functions as views in your urls.py.
Is a very simple atlassian crowd integration, I know the client soap requests are not so elegant but they work perfecly! you need to install amara ..
Please delete the snippet.
Based on [this snippet](http://www.djangosnippets.org/snippets/660/), adapted to split a list into *n* number of sublists, e.g. split a list of results into three evenly-divided sublists to enable display of the results in three columns on one page with CSS. Tag: `{% list_to_columns your_list as new_list number_of_columns %}` The split_seq solution comes from a comment by Sebastian Hempel on [this post](http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425397). More info [here](http://herself.movielady.net/2008/07/16/split-list-to-columns-django-template-tag/).
Template tag for displaying a list of arbitrary models. Useful for life-stream kind of pages that display blog entries, links, photos etc ordered by date. [Example](http://bjornkri.com) **Usage:** something like: {% for object in object_list %} {% display_excerpt object %} {% endfor %} Will look for *app/model_excerpt.html* by default, and fall back on a generic *display_excerpt.html*, or returns the object's string representation as a last fallback. *display_excerpt.html* might look something like: <a href="{{ object.get_absolute_url }}">{{ object }}</a> Any model you throw at it should have a *get_absolute_url* and a string representation of some sort, so this gives you the bare minimum of a title and a link to a detail page. *display_excerpt* takes an optional argument to set the template suffix. This might be handy for generating different formatting for feeds, for instance: {% for object in object_list %} {% display_excerpt object "feed" %} {% endfor %} This will look for app/model_feed.html to render the object. Got lots of help from mattmcc on #django for this one, thanks!
** Help me get better! If you vote (either way) please leave a comment if you have time and say what was good or bad. I appreciate any and all feedback. Thanks! ** I keep finding places in my apps where I need an isolated snippet of text that can periodically be changed from the admin interface. Most often it's html but sometimes it's text, javascript, or css. Use it like so: (Assuming this snippet lives in snippy_snip/models.py and there is a snippet named "Welcome Message" in the database) from snippy_snip.models import snip msg = snip("Welcome Message") Or, you might populate a parameter hash for a template: def showpage(request): params = { 'welcome': snip('Welcome Message'), 'video1': snip('Video 1'), 'NavHeader': snip('Nav.SectionHeader'), } return render_to_response("main.html", params) For clarity, *params* might look something like this: welcome -> "Welcome to our site. Please use the menu on the left..." video1 - > a YouTube snippet NavHeader -> Some HTML which comprises the top of a navigation menu. This is a very simple bit of code but I've found it very useful. It isn't intended for instant changes... Your snippets will cache like anything else, which may cause confusion if you expect immediate changes. And it's probably not great for a high traffic site, but for my moderate traffic sites and workgroup apps I've found it useful. (This code was created for 0.96, but I'm working to bring it into alignment with the latest svn version of Django, see comments.)
This snippet is based on [#844](http://www.djangosnippets.org/snippets/844/) and updates all apps in the current directory using hg, svn, git or bzr.
This adds a checkbox in the admin site that removes the reference to a file uploaded via a FileField (or ImageField). It does not delete the actual file.
A script I wrote a little while ago to help speed up newforms-admin conversion. From memory it works best when run from an old-forms installation, but it is still useful post-conversion. There are some features missing, but it's supposed to be a starter. Just install this command and run: ./manange.py port2nfa > admin.py (To install, copy the file to management/commands/port2nfa.py in an app somewhere)
If you view Django's admin pages as a convenience for experts, and so don't see the point in heavily modifying it beyond a few simple things like list_display and some ordering or filtering options, you may feel that newforms-admin makes things harder, not easier. ... Well, there's some truth to that, but it turns out that fighting newforms-admin is doomed - too much has changed to make the fight to preserve the old simplicity winnable to any useful extent, so I'm withdrawing this.
This simply deletes all compiled python files in a folder.