Skip to content

Having trouble with Relationship between models #3

Description

@gmartindelcye

When trying to create let say a role table and permission table with the relation role->permissions, when using the prefix to name the tables and using the same to set the foreign_key produce the error:

prefix = "rol"

Foreign key associated with column 'rol_permissions.role_id' could not find table 'rol_roles' with which to generate a foreign key to target column 'id'

If I change the f"{prefix}_roles" with "rol_roles" both in the name and the foreign key it works.

  1. Is there a flag or what can I do to maintain the same code and have relationship between tables?
  2. What about using relationship between models from different models?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions