Login

Add

Author:
jmunro
Posted:
March 17, 2012
Language:
Python
Version:
1.3
Tags:
groups
Score:
0 (after 0 ratings)

Based on an answer here: http://stackoverflow.com/a/6288863

1
2
3
4
5
6
from django.contrib.auth.models import Group, User

new_user = User(username="foo", password="bar")

example_group = Group.objects.get(name="<GROUP_NAME>")
example_group.user_set.add(new_user)

More like this

  1. create or update, then get, model instances from JSON/py dict by anentropic 3 years, 5 months ago
  2. Form widget for text inputs with external link. version2 by ramusus 5 years, 11 months ago
  3. Modify properties on fields inherited from an abstract superclass by andybak 10 months, 4 weeks ago
  4. Alternative to Class Based Views by sleepycal 2 years, 8 months ago
  5. Auto-create Django admin user during syncdb by statico 5 years, 4 months ago

Comments

Please login first before commenting.