Skip to content

Instantly share code, notes, and snippets.

@patelsarang9517
Created April 14, 2019 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patelsarang9517/1a9b4905186b5d3d9715ef78b715b363 to your computer and use it in GitHub Desktop.
Save patelsarang9517/1a9b4905186b5d3d9715ef78b715b363 to your computer and use it in GitHub Desktop.
Managing groups in Django Channels
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