DualPasswordForm is a simple form that contains two password fields and validation to ensure that the two passwords match. A minimum password length of 7 characters is imposed, but feel free to change that.
Refactors two similar django template files to use `{% block %}` tags.
Takes two template files, where one is a modified version of the other, and looks for differences and similiarities between the two.
It then generates refactored (and renamed) versions of each file and a third 'base' file, adding an `{% extends %}` tag as appropriate.
Block tags are named with matching numbers in all 3 files, making it easy to do a search and replace with more meaningful labels.
`sample_data_in_base` controls whether or not the content from file 1 is copied into place in the base file as an example.
Problems: it doesn't identify open `{% for %}` or `{% if %}` tags, so this needs some manual fixing (moving the `{% endfor %}` and `{% endif %}` tags into the proper blocks). It doesn't add the correct path for the `{% extends %}` tag either (ie. `"app/base.html"`). `collapse_whitespace` is not working at all.
This snippet uses the [django-environment project](http://code.google.com/p/django-environment/). Django-environment is used to provide "environment variables" to django apps.
This snippet uses the [django-environment project](http://code.google.com/p/django-environment/). Django-environment is used to provide "environment variables" to django apps.
This simple middleware rewrites the 'href' attribute of any `<a>` tags in your response content. The URL href is modified by appending the string '.nyud.net', which causes the Coral Content Distribution Network to retrieve a copy of the page and cache it before returning it to the user agent.
This might be useful if you're writing another Slashdot and you want to avoid turning the servers you link to into smoking craters.
You [should be able](http://www.djangosnippets.org/snippets/910/) to apply this functionality to a single view as well (though I haven't tried this yet).
Django 0.96 seems to have a bug when serializing from MySQL. BooleanFields are encoding as 0/1 instead of true/false. Hacking the python serializer seems to fix that.
The bug shows up as (fx. when using loaddata on a dump from MySQL in PostgreSQL):
Problem installing fixture '/tmp/data.json': ERROR: column "is_staff" is of
type boolean but expression is of type integer
HINT: You will need to rewrite or cast the expression.
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.
There has been some discussion about removing `auto_now` and `auto_now_add` some time ago. `auto_now_add` can be replaced be using a callable default value, `auto_now` can't. So I wrote this litte function for my current project (older ones still use `auto_add`) to fill the gap...but I'm not sure if `auto_now` will be removed at all.
Extension of the idea from [WuzHere example from Google IO](http://code.google.com/p/wuzhere/) about creating one compressed js or css file. Original code used not very elegant if statements. I've changed it to template tags. On production server it will also use current version id.
Insert code in *cssjs.py* file in *templatetags* dir in your application and use as below (more details in docs):
`<script type="text/javascript" src="/media/jsmergefile.js"></script>`
**This code does not compress CSS and JS on the fly, because GAE is read-only and using Datastore is too heavy.**
You're looking at the most-bookmarked snippets on the site; if you'd like to help useful snippets show up here, sign up for an account and you'll get your own bookmarks list.