What is the Django command to access a related attribute in a many-to-many relationship (not related_name) -
in django, have model called articles. each article has attribute called "comments_on". attribute has many-to-many relationship articles criticizes. related_name attribute "commented_on_by". means if article1 criticizes article2, article2.commented_on_by point article1. question how access article2 article1? in other words, i'd write article1.[something] access article2. thank you.
you need take query set imagine models
class a(models.model) name = models.charfield(max_length=128, null=true, blank=true) class b(models.model) name = models.foreignkey(user, blank=true, null=true) = models.manytomanyfield(a, blank=true, null=true) you should query
amodels= b.a.all()
Comments
Post a Comment