How to join ManyToMany querysets in Django/Python -


for example, have 2 models:

class user(abstractuser):    achievement = models.manytomanyfield('achievement')  class achievement(models.model):     name = models.charfield(max_length=50) 

i need achievements of several users, think, should this:

for user in user.objects.filter(bla-bla):   achievement_list += user.achievement 

but returns error "'manyrelatedmanager' object not iterable"

user.achievement manyrelatedmanager, similar how, say, achievement.objects manager. try instead user.achievement.all() or user.achievement.filter(...) (with whatever filter may want).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -