Hello! I can't extend many-to-many relationship in sqlalchemy. Here's my code:
async def create_article(session: AsyncSession, topic: TopicEnum,
users_ids: List[int], inactive_at: datetime
ValueModel = create_model('ValueModel', topic=(TopicEnum, ...),
inactive_at=(datetime, ...))
article = await ArticleDAO.add(session=session, values=ValueModel(topic=topic,
inactive_at=inactive_at))
users = await UserDAO.find_all(session=session, filters=None, filter_lmbd=lambda a: a.id in users_ids)
await article.liked_by.extend(users)
Full error is in the attachment. What am I doing wrong? From the previous answers I got that I need to do it asynchronously, but it seems like I can't. I want to extend the relationship, add new users to it. When I try to access it via awaitable_attrs it throws coroutine has no method called extend(), and when I separate it into another variable and call extend on that it throws object of NoneType has no method called extend(). I don't have any lazy loading here afaik (I might be wrong). I know the primary keys of models I want to add to the relationship and the model that has that relationship. Can someone tell me the way to do it properly?