#15833: Exclude not working with ForeignKey in admin Inlnes
---------------------------+------------------------------
Reporter: claytongulick | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: contrib.admin
Version: 1.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 |
---------------------------+------------------------------
I have a simple model:
{{{
class ImageFile(models.Model):
name = models.CharField(max_length=50, help_text="The textual name for
the image, maximum of 50 chars")
gallery = models.ForeignKey(Gallery,help_text="Select the gallery that
this image belongs to",blank=True,null=True)
image_file =
models.ImageField(upload_to="site/%s/images/"%(settings.SITE,),help_text="Select
an image file to upload")
display_order = models.IntegerField(blank=True,null=True,help_text="An
optional field used for ordering the rows visually")
content_type = models.ForeignKey(ContentType) #reference to the magic
contentTypes table
object_id = models.PositiveIntegerField() #the generic ID of the table
we're relating to
content_object = generic.GenericForeignKey('content_type','object_id')
#a generic reference is a relation that defines a) the id of the table we
refer to, and b) the id of the row we're rel
def __unicode__(self):
return self.name
class Meta:
ordering = ['display_order']
}}}
Using that model as an inline, I want to exclude the gallery field,
because it is optional, like this:
{{{
class ImageFileInline(generic.GenericTabularInline):
model=ImageFile
exclude=('gallery',)
}}}
That results in this error:
ImproperlyConfigured at /admin/consumer/product/add/
ImageFileInline cannot exclude the field 'gallery' - this is the foreign
key to the parent model Gallery.
However, if I use this instead, it works fine:
{{{
class ImageFileInline(generic.GenericTabularInline):
model=ImageFile
fields=('name','image_file','display_order',)
}}}
If I can remove the field by not including it in the list of fields, I
should also be able to exclude the field.
Thanks!
--
Ticket URL: <http://code.djangoproject.com/ticket/15833>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en.