vittoriozamboni / django-groups-manager

Manage django groups collection based on django-mptt.
MIT License
100 stars 23 forks source link

Django custom user model and Member #58

Closed nikhilnaregal closed 2 years ago

nikhilnaregal commented 2 years ago

Note: I am using a custom user model in Django and not a default user model (replaced username with email)

def create_member(sender, instance,created, **kwargs):
    if created:
        if not instance.is_staff:
            try:
                Member.objects.create(first_name=instance.first_name, last_name=instance.last_name, django_user_id=instance.id)
            except:
                pass

post_save.connect(create_member,sender=User)

This creates an instance of Member when an instance of CustomUser is created, but Under customuser the users email disappears. If I remove "django_user_id=instance.id" everything is normal but, django_user is unassigned as expected.

How can I create an instance of member class ?