Snippet List
My problem was that I needed user names with fullstops in them (eg dodgy.ville), but the slugfield on the admin form was rejecting them. This small snippet overrides the validation field on the admin form,
To use it: place it in your admin.py
I prefer to use this slugification function rather than the one included with Django. It uses underscores instead of dashes for spaces, and allows dashes and periods to occur normally in the string. I decided on this when considering reasonable slugified titles such as...
object-relational_mapper_2.5
ten_reasons_web-2.0_rocks
django-trunk_0.99_updated
- filter
- slugs
- slug
- slugify
This code is derived from the slugify JS function used in django's admin interface. It will create django-compatible slugs for you. Sometimes I do batch imports and need my items to have slugs, I give this script the item's title and get a slug back.
Simple
3 snippets posted so far.