def __init__(self, *args, **kwargs): super(NodeForm, self).__init__(*args, **kwargs) categories = categories_for_forms() for category in categories: name = normalize_string(category.name) self.fields[name] = forms.CharField(max_length=500, label=category.name, required=False, widget=forms.TextInput(attrs={ 'class': 'tags input-xxlarge'} ))
def is_unique(self): value = normalize_string(self.cleaned_data['name']) return Category.objects.filter(name=value).count() == 0