I have made modular architecture in fast api and getting error as shown
sub_department.py
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.orm import relationship
from src.db import Base
class SubDepartment(Base):
__tablename__ = 'sub_department'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String, index=True, unique=True)
department_id = Column(Integer, ForeignKey('department.id'))
department = relationship('Department', back_populates='sub_departments')
consultation_appointment = relationship('ConsultationAppointment', back_populates='sub_department')
department.py
class Department(Base):
__tablename__ = 'department'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String, index=True, unique=True)
sub_department = relationship('SubDepartment', back_populates='department')
doctor = relationship("Doctor", back_populates='departments')
error
if I import all model in main.py or init.py it works but it’s unused and i do not think it’s the way to fix. how to fix this issue and make sure importing all models in main.py is not best practice.