Last active
September 11, 2016 07:00
-
-
Save bluethon/799c61c573104f2827cb35ee7707b2d8 to your computer and use it in GitHub Desktop.
group attribute demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class some(): | |
groups = models.ManyToManyField( | |
Group, | |
verbose_name='组', | |
blank=True, | |
# help_text='The groups this user belongs to. A user will get all ' | |
# 'permissions granted to each of their groups.', | |
related_name="user_set", | |
related_query_name="user", | |
) | |
def func(): | |
new_group, created = Group.objects.get_or_create(name='campaign') | |
if new_group: | |
user.groups.add(new_group) | |
else: | |
user.groups.add(created) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment