Here's what I'm trying to do, and failing...
I have a File model which has a generic-relation to other objects:
class File(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
file = models.FileField(upload_to='files/%Y/%m/%d')
# etc....
I also want to have a sub-class of File to deal with the specific case of images to be displayed in-page, rather than downloaded:
class Image(File):
file = models.ImageField(upload_to='files/%Y/%m/%d')
All of the above works fine, including generic inlines of the File model, until I want to use a generic-inline of the Image model --- the save process fails to create the base class instance and so raises an error stating that the Image.file_ptr (the 'secret' foreign key to the base class) cannot be None.
So, basically, generic inlines do not properly support multi-table inheritance at the moment.
It's quite likely that I'm making this more complicated than it need be, so can anyone suggest either a fix for this problem, or a better way of achieving the same end?
Please let me know if you need further clarification.