Hi all, Just wondering if anyone has come across the following problem, and if there is a way around it...
I'm using both multi-table inheritance and generic relations to maintain a central repository of both general files, and display images in the following, simplified, way,: # # models.py # class File(models.Model): """ This base class defines the generic relationship and all properties common to all files """ content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey() title = models.CharField(max_length=100) file = models.FileField(upload_to='files/%Y/%m/%d') class Image(File): """ Override the base class file field to access image specific properties of the ImageField """ file = models.ImageField(upload_to='files/%Y/%m%d') # # admin.py # class FileInline(generic.GenericStackedInline): model = File extra = 1 class ImageInline(generic.GenericStackedInline): model = Image extra = 1 The generic inlines above are then imported into the admin.py of any app which needs them and are referenced via the ModelAdmin's inlines as you'd expect. Now here's the problem... saving a File object via the generic inline works as expected, but saving an Image via it's generic inline raises the following error: Cannot assign None: "Image.file_ptr" does not allow null values. django/db/models/fields/related.py in __set__ 253. if instance is None: 254. raise AttributeError, "%s must be accessed via instance" % self._field.name 255. 256. # If null=True, we can assign null here, but otherwise the value needs 257. # to be an instance of the related class. 258. if value is None and self.field.null == False: 259. raise ValueError('Cannot assign None: "%s.%s" does not allow null values.' % >>> 260. (instance._meta.object_name, self.field.name)) 261. elif value is not None and not isinstance(value, self.field.rel.to): 262. raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s" instance.' % 263. (value, instance._meta.object_name, 264. self.field.name, self.field.rel.to._meta.object_name)) 265. 266. # Set the value of the related field I'm running on SVN trunk as of changeset #9506, BTW. It seems to me that the generic inline is not correctly handling the _ptr foreign-key connecting the Image instance to it's parent File instance. If anyone can shed light on this, even if it's just a link to the appropriate ticket number that would be greatly appreciated. If you need additional info please let me know. With best regards Mike --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---