You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to use one table for all the images associated with one object/model? It appears that two tables are required as illustrated by the UserPicture and UserFrontCover relationships in the sqlalchemy_imageattach.entity module documentation.
Given the above model, SQLAlchemy can't determine the join condition. When I've come across this before, I generally have the foreign key on the "parent", in this case the User model and looks like this:
Is there a reason you chose to store the foreign key on the Image model? Is there a way of getting around requiring two tables? Or am I just missing some configuration option to avoid using two tables?
The text was updated successfully, but these errors were encountered:
You can put any arbitrary columns to UserImage class e.g. type, and union two types of images (avatar_image and background_image) into one table and distinguish two by filtering type column.
Is it possible to use one table for all the images associated with one object/model? It appears that two tables are required as illustrated by the
UserPicture
andUserFrontCover
relationships in thesqlalchemy_imageattach.entity
module documentation.I'd much prefer something like:
Given the above model, SQLAlchemy can't determine the join condition. When I've come across this before, I generally have the foreign key on the "parent", in this case the
User
model and looks like this:Is there a reason you chose to store the foreign key on the
Image
model? Is there a way of getting around requiring two tables? Or am I just missing some configuration option to avoid using two tables?The text was updated successfully, but these errors were encountered: