I tried following Code with the help of the django.contrib.auth.User and django.contrib.auth.Group
for g in request.user.groups
This is better
if user.groups.filter(name='groupname').exists(): # Action if existing else: # Action if not existing