Fetch and count all records in M2M join table
I have two tables that are in M2M relationship. I have not created explicit model for the join table.
class CustomUser(AbstractUser):
class Meta:
app_label = "users"
db_table = "users"
class Listing(models.Model):
bookmarks = models.ManyToManyField(CustomUser, related_name="bookmarked_listings", blank=True)
class Meta:
app_label = "listings"
db_table = "listings"
How can I fetch and count all records in the join table, listing_bookmarks? I don't mean just getting bookmarks of a listing or bookmarked listings of an user.