-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Piccolo-Admin is unable to understand target_column arg of ForeignKey columns #362
Comments
@aabmets You are right, non-primary FK does not work in admin. Here's an old issue for that. There was a PR to fix that problem, but somehow it got stuck and I closed it. I don't know if it's even valid code on the backend now and I'm sure it's not valid on the frontend because a lot of changes were made moving from Vue2 to Vue3. |
@aabmets If you have the will and time, you can try the changes required to make the non-primary key work in Piccolo Admin. from piccolo_admin.endpoints import TableConfig, create_admin
elements_config = TableConfig(
table_class=ElementsTable, target_column=[ClassificationsTable.code]
)
APP = create_admin([elements_config]) I hope this is useful. |
@sinisaos I'm glad that code still exists. It's something we need to add at some point. All of the projects I have use quite simple foreign keys (just to primary keys), so I haven't had a chance to properly test it. |
@sinisaos Thank you for a possible solution. I went with another route: defined the column as the same type as the column in the referenced table and used a raw migration to create a foreign key constraint between the two. |
I created tables with these definitions:
In piccolo-admin web GUI, I attempted to insert a value from the referenced target
column into the
classification_code
column of themeta_elements
table.The admin GUI has hardcoded expectation that ForeignKeys only reference the ID column of referred tables
and it does not even allow me to manually type a value for the
classification_code
column.The constraint itself is created correctly in the Postgres database:
These inconsistencies between the components make ForeignKeys unusable together with Piccolo-Admin.
Please put more effort into checking the quality and coherence of your source code.
The text was updated successfully, but these errors were encountered: