Skip to content

Piccolo-Admin is unable to understand target_column arg of ForeignKey columns #362

@aabmets

Description

@aabmets

I created tables with these definitions:

class ElementsTable(Table, tablename="meta_elements", schema=AppConfig.DB_SCHEMA):
    classification_code = ForeignKey(
        references=tables.ClassificationsTable,
        target_column=tables.ClassificationsTable.code,
        on_delete=OnDelete.cascade,
        on_update=OnUpdate.cascade,
        default=None,
        required=True,
        null=False
    )
class ClassificationsTable(Table, tablename="meta_classifications", schema=AppConfig.DB_SCHEMA):
    code = Varchar(
        length=40,
        unique=True,
        required=True,
        null=False
    )
    # other columns omitted due to irrelevance

In piccolo-admin web GUI, I attempted to insert a value from the referenced target
column into the classification_code column of the meta_elements table.
image

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:
image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions