[Fixed]-Add images to a children class

1👍

Since the FK is from Foo (and its children) to FooImage, and not the other way round, it makes no difference that you are using inheritance here: you can add the images directly to the FooBar instance as if it were a standalone one.

my_foo_bar = FooBar.objects.create(field=value)
my_foo_bar.images.add(my_foo_image)
# or
FooImage.objects.create(model=my_foo_bar, image=my_image)

Leave a comment