I faced a problem, when I create models everything goes smoothly, but when I try to make any query I get this error
class Phone(Base):
__tablename__ = 'phone'
id: Mapped[int] = mapped_column(primary_key=True)
number: Mapped[str] = mapped_column(PhoneNumberType(region="BY"), unique=True)
contact_id: Mapped[int] = mapped_column(ForeignKey('contacts.id'))
contacts: Mapped[list['Contacts']] = relationship('Contacts', back_populates='phone')
class Socials(Base):
__tablename__ = 'socials'
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column()
url: Mapped[str] = mapped_column(unique=True)
contact_id: Mapped[int] = mapped_column(ForeignKey('contacts.id'))
contacts: Mapped[list['Contacts']] = relationship('Contacts', back_populates='socials')
class Contacts(Base):
__tablename__ = 'contacts'
id: Mapped[int] = mapped_column(primary_key=True)
address: Mapped[str] = mapped_column()
social: Mapped[list['Socials']] = relationship('Socials', back_populates='contacts')
phone: Mapped[list['Phone']] =relationship('Phone', back_populates='contacts')
When executing any query, an error occurs: sqlalchemy.exc.InvalidRequestError: Mapper ‘Mapper[Contacts(contacts)]’ has no property ‘socials’. If this property was indicated from other mappers or configure events, ensure registry.configure() has been called.
New contributor
Павел Наркевич is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.