AttributeError Group object has no attribute user

0 votes

How to add users in group?

I have created a group and given appropriate permissions to. But am not able to add users to that group.

Example
>>> admin
<Group: group_admin>
Now adding user to the group example text
>>> admin.user.add(test)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'Group' object has no attribute 'user'
Nov 12, 2020 in Python by anonymous
• 8,910 points
1,687 views

1 answer to this question.

0 votes

You can go through this:

from django.contrib.auth.models import User, Group
  my_group = Group.objects.get(name='groupname')
   my_users = User.objects.filter(<your_filter>)
   for my_user in my_users:
   my_group.user_set.add(my_user)
answered Nov 12, 2020 by Gitika
• 65,850 points

Related Questions In Python

0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,540 points
7,476 views
0 votes
1 answer
0 votes
2 answers

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

Try this: data=pd.read_csv('/your file name', delim_whitespace=Tru ...READ MORE

answered Dec 10, 2020 in Python by anonymous
• 82,680 points
98,338 views
0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

answered Jun 19, 2019 in Python by Faiza
4,291 views
0 votes
1 answer

How to rename columns in pandas (Python)?

You can use the rename function in ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by MD 947 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is "size" includes NaN values, ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by Gitika 1,773 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
10,703 views
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,660 points
3,766 views
0 votes
1 answer

AttributeError: type object 'DataFrame' has no attribute 'from_items'

Hi, @Bronson, You can go through this, I ...READ MORE

answered Apr 6, 2020 in Python by Gitika
• 65,850 points
3,824 views
0 votes
3 answers

AttributeError: 'numpy.ndarray' object has no attribute 'append'

for root, dirs, files in os.walk(directory): ...READ MORE

answered Dec 12, 2020 in Python by Rajiv
• 8,910 points
47,180 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP