I have implemented this solution successfully with a standard model,
but when I try to use it on one which is subclassed I get an error
because it is trying to validate the model before it knows about the
subclass.  I can work around this by defining an Admin class for each
of the subclasses, but it seems to me this should work?

Model.py

class Directory(models.Model):
    name = models.CharField(max_length=60)
    pic1 = models.ImageField(upload_to='pics', blank=True,
null=True)

class Business(Directory):
    cat = models.ForeignKey(Subcategory)


Admin.py

AdminImageWidget defined ....

class DirectoryAdminForm(forms.ModelForm):
    pic1 = forms.ImageField(widget=AdminImageWidget())

    class Meta:
        model = Directory

class DirectoryAdmin(admin.ModelAdmin):

    form = DirectoryAdminForm

    fieldsets = [
        (None,   {'fields': ['cat','name','is_live']}),    <--------
CAT FIELD IS PART OF BUSINESS NOT DIRECTORY SO CAUSES ERROR
        ('Contact', {'fields':
['phone','mobile','fax','email','web','address']}),
        ('Details', {'fields':
['description','pic1','pic2','pic3','pic4']}),
    ]

admin.site.register(Business,DirectoryAdmin)


Error

ImproperlyConfigured at /admin/town/business/14/

'DirectoryAdmin.fieldsets[2][1]['fields']' refers to field 'cat' that
is missing from the form.

Request Method:         POST
Request URL:    http://dunmanway.pighaswings.com/admin/town/business/14/
Exception Type:         ImproperlyConfigured
Exception Value:

'DirectoryAdmin.fieldsets[2][1]['fields']' refers to field 'cat' that
is missing from the form.

Exception Location:     /usr/lib/python2.4/site-packages/django/contrib/
admin/validation.py in check_formfield, line 255



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to