I have made a group “general” from admin panel.
Now I want when a new user register to my app it will by default assign to this group and user_id and group_id stored in intermediate table of auth_user and auth_group.
Actually I have tried this myself and getting errors.
EDIT
def signup(request, template="accounts/account_signup.html"):
"""
Signup form.
"""
profile_form = get_profile_form()
form = profile_form(request.POST or None)
#return render_to_response('test.html',{'q':email},context_instance=RequestContext(request))
if request.method == "POST" and form.is_valid():
new_user = form.save()
group_id=Group.objects.get(id=1)
group_id.groups.add(new_user)
#group = User_Groups(user=new _user,group=1)
#group.save()
last_inserted_id = User.objects.order_by('-id')[0]
value_email = last_inserted_id.email
...............
Error
‘Group’ object has no attribute ‘groups’
This, to begin with, will help you understand the error you’re getting
Here,
group_idbecomes an instance of the modelGroup.Groupand its instances have attributesname, andpermissions.Is nonsense.
groupsis an attribute ofUserand notGroup.Replace group_id with new_user :
This will add group_id (which should be named group instead) to the list of groups new_user is member of.