Hi everyone, Been bashing against this one for a while now and am keen for suggestions. I'm trying to apply custom validation to forms within Django's default admin. First up, I want to strip out all html from a Title field. Following the official documentation I have developed this:
---------------------------- from django.contrib import admin from django import forms from django.utils.html import strip_tags from queryclick.qc_news.models import * #Custom Data Validation in the Admin Interface class MyArticleAdminForm(forms.ModelForm): class Meta: model = Article def clean_title(self): #Remove all HTML, using strip_tags (import from django.utils.html title = self.strip_tags('title') #Always return cleaned data return self.cleaned_data["title"] class ArticleAdmin(admin.ModelAdmin): list_display = ('title', 'client', 'submitted_date', 'edited_date', 'go_live_date') list_filter = ('client', 'submitted_date', 'edited_date', 'go_live_date') ordering = ('-submitted_date',) search_fields = ('title','client',) form = MyArticleAdminForm admin.site.register(Copywriter) admin.site.register(Client) admin.site.register(Article, ArticleAdmin) ---------------------------- But get an Attribute Error: 'ArticleForm' object has no attribute 'strip_tags' from line 13: title = self.strip_tags('title') Any and all suggestions warmly welcomed! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---