python - Disallow generic inline to add extra content object -
i have generic foreign key restricted single content object setting unique_together in metaclass explained here.
class image(models.model): image = models.imagefield(upload_to="images") content_type = models.foreignkey(contenttype, on_delete=models.cascade) object_id = models.positiveintegerfield() content_object = genericforeignkey("content_type", "object_id") class meta: unique_together = ('content_type', 'object_id') class product(models.model): name = models.charfield(max_length=100)
and i'm using genericinlinemodeladmin render admin page. looks genericinlinemodeladmin made many 1 relationship.
class imageinline(generictabularinline): model = image class productadmin(admin.modeladmin): inlines = [ imageinline, ]
my admin page has multiple inline forms image #1, image #2, image #3 , has button add image. adding multiple images not work (as expected) , results in error i'm looking way tell genericinlinemodeladmin onetoone relationship.
i add rid of 3 inline image forms on page render.
class imageinline(generictabularinline): model = image = 1
is there way remove "add image" button admin page?
Comments
Post a Comment