django get group users

from django.contrib.auth.models import Group

# Step 1: Get the group object by its name
group_name = 'your_group_name'
try:
    group = Group.objects.get(name=group_name)
except Group.DoesNotExist:
    # Handle the case where the group doesn't exist
    pass

# Step 2: Get the users associated with the group
if group:
    group_users = group.user_set.all()

    # Step 3: Access user information if needed
    for user in group_users:
        username = user.username
        email = user.email
        # Access other user properties as needed