-
-
Save patelsarang9517/1a9b4905186b5d3d9715ef78b715b363 to your computer and use it in GitHub Desktop.
Managing groups in Django Channels
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 User(AbstractBaseUser, PermissionsMixin): | |
""" | |
Maintain user and its attributes | |
""" | |
@property | |
def group_name(self): | |
""" | |
Returns a group name based on the user's id to be used by Django Channels. | |
Example usage: | |
user = User.objects.get(pk=1) | |
group_name = user.group_name | |
""" | |
return "user_%s" % self.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment