hi, i'm trying to use a custom form for one of my models inside the admin interface . i need this to do custom validation.
so far, i have created a DocumentForm that inherits from newforms.ModelForm and define my Model as model attribute inside the Meta class (as seen at http://www.djangoproject.com/documentation/modelforms/) --- from django import newforms as forms class DocumentForm(forms.ModelForm): class Meta: model = models.Document --- then i overwrote form_add and form_change in my Options class: --- from django.contrib.admin import ModelAdmin class DocumentOptions(ModelAdmin): def form_add(self, request): if self.declared_fieldsets: fields = flatten_fieldsets(self.declared_fieldsets) else: fields = None return forms.form_for_model(self.model, form=DocumentForm, fields=fields, formfield_callback=self.formfield_for_dbfield) def form_change(self, request, obj): if self.declared_fieldsets: fields = flatten_fieldsets(self.declared_fieldsets) else: fields = None return forms.form_for_instance(obj, form=DocumentForm, fields=fields, formfield_callback=self.formfield_for_dbfield) admin.site.register(models.Document, DocumentOptions) --- but now i get an error when trying tro add or edit a document: Exception Type: TypeError Exception Value: 'NoneType' object is not callable Exception Location: /usr/lib/python2.5/site-packages/django/newforms/ models.py in __init__, line 270 Traceback: [..] File "/usr/lib/python2.5/site-packages/django/newforms/models.py" in __init__ 270. self.instance = opts.model() i don't understand why calling opts.model() fails. this should be exactly my Document model which i defined inside the Meta class. Did i miss something or whats wrong there? regards, lowshoe --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

