Python Snippets List Comprehension Example: m2mid_list = [m2m_item.pk for m2m_item in my_model.my_m2m_field.all()]