How to get values from ManyToManyRelationManager objects
See original GitHub issue# Model like this
class Permission(Model):
id = IntField(pk=True)
name = CharField(max_length=160)
def __str__(self):
return self.name
class Role(Model):
id = IntField(pk=True)
name = CharField(max_length=160)
permissions = ManyToManyField('models.Permission', related_name='perm')
create_time = DatetimeField(auto_now=True)
def __str__(self):
return self.name
# Handler like this
class RoleHandler(RequestHandler):
async def get(self, *args, **kwargs):
role = await Role.all()
for r in role:
print(i.permissions)
<tortoise.fields.ManyToManyRelationManager object at 0x7fcb78126668>
How to get values from ManyToManyRelationManager objects ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Django DetailView getting values of ManyToMany ...
You can get the post tags with self.object.tags.all() so it will be something like :
Read more >Many-to-many relationships
To define a many-to-many relationship, use ManyToManyField . In this example, an Article can be published in multiple Publication objects, and a Publication ......
Read more >The right way to use a ManyToManyField in Django
To maintain a many-to-many relationship between two tables in a database, the only way is to have a third table which has references...
Read more >Tips for Using Django's ManyToManyField
Tips for Using Django's ManyToManyField · Both objects must exist in the database · To retrieve the stuff in a ManyToManyField , you...
Read more >Related objects reference — Django 4.1.4 documentation
You can use the bulk=False argument to instead have the related manager perform the update by calling e.save() . Using add() with a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry,
await i.permissions._query
without ()Hi, can you please check if your issue has been resolved with v0.11.4? The documentation has also been updated.