Hello! I'm using FastApi Admin. It works fine, but in one case I've got a problem.
I have ManyToMany Relation in Admin section I can create and delete data, but I can't update data because this error: raise NoValuesFetched(
tortoise.exceptions.NoValuesFetched: No values were fetched for this relation, first use .fetch_related())
Resource:
class PageResource(resources.Model):
label = "Page"
model = Page
fields = [
"id",
"content",
Field(name="type_id",
label="Page type",
input_=inputs.ForeignKey(model=PageType),
),
Field(name="user_id",
label="User",
input_=inputs.ForeignKey(model=User),
),
Field(name="audios",
label="Audio",
display=displays.InputOnly(),
input_=inputs.ManyToMany(model=Audio),
),
Field(name="videos",
label="Video",
display=displays.InputOnly(),
input_=inputs.ManyToMany(model=Video),
),
]
class:
class Page(models.Model):
"""
The Page model
"""
id = fields.BigIntField(pk=True)
content = fields.TextField(null=False)
user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField(
"models.User", related_name="pages", on_delete=fields.CASCADE)
type: fields.ForeignKeyRelation[PageType] = fields.ForeignKeyField(
"models.PageType", related_name="pages", on_delete=fields.CASCADE)
videos: fields.ManyToManyRelation[Video] = fields.ManyToManyField(
"models.Video", related_name="pages", forward_key="video_id", backward_key="page_id",
through="page_video"
)
audios: fields.ManyToManyRelation[Audio] = fields.ManyToManyField(
"models.Audio", related_name="pages", forward_key="audio_id", backward_key="page_id",
through="page_audio"
)
Please help me to manage this problem!