Skip to content

Bug: Required foreign key is empty #485

@mlachowski

Description

@mlachowski

Describe the bug
When creating a new entity which has required related model I've got an error.

To Reproduce

class Company(SQLModel, table=True):
    id: int = Field(default=None, primary_key=True)
    name: str 
    facilities: List["Facility"] = Relationship(back_populates="company")

class Facility(SQLModel, table=True):
    id: int = Field(default=None, primary_key=True)
    name: str
    company_id: int = Field(foreign_key="company.id")
    company: Company = Relationship(back_populates="facilities")

During saving the Facility there is an 422 http error and "{'company_id': 'Field required'}" in errors.

Environment (please complete the following information):

  • Starlette-Admin version: starlette-admin = {extras = ["i18n"], version = "^0.13.0"}
  • ORM/ODMs: SQLModel sqlmodel = "^0.0.14"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions