create django group

To create a Django group, follow these steps:

  1. First, import the necessary modules:
from django.contrib.auth.models import Group
  1. Then, create the group using the Group.objects.create method:
new_group, created = Group.objects.get_or_create(name='new_group_name')
  1. Next, assign permissions to the group using the group.permissions.add method:
new_group.permissions.add(permission1, permission2)
  1. Finally, save the group to apply the changes:
new_group.save()