Snippet List
This code assumes your XFN field is called 'rel' in models. See the last call (addLoadEvent down the bottom) for the two lines requiring modification; otherwise, aside from the Django-styling involved, it can be used anywhere.
The accompanying model.py and admin.py information can be found here: [http://www.djangosnippets.org/snippets/1265/](http://www.djangosnippets.org/snippets/1265/).
I'm no master programmer, so feedback/comments/criticism is more than welcome.
EDIT: Fixed my esoteric dev. comments and removed references to spawning more overlords.
Slightly different validation to that of jpwatts; developed with knowledge of that snippet but written up from scratch for use as a fallback for when the Javascript Assist is off.
I'm no master programmer, so feedback/comments/criticism is more than welcome.
The accompanying Javascript (xfn-admin.js) can be found here: [http://www.djangosnippets.org/snippets/1266/](http://www.djangosnippets.org/snippets/1266/).
**This is a newforms field for XFN relationships.**
It normalizes input by removing excess whitespace, converting to lowercase and removing duplicates.
This field also validates the relationship according to the [XFN profile](http://gmpg.org/xfn/11): `me` can only appear by itself and, at most, one value from each of the family, friendship and geographical categories is allowed.
The `XFN_*` constants would probably be imported from somewhere else in practice, but are included here for simplicity.
- newforms
- fields
- forms
- form
- field
- xfn
3 snippets posted so far.