from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from imagerprofile.models import ImagerProfile


@receiver(post_save, sender=User)
def add_profile(sender, instance, **kwargs):
    if kwargs['created']:
        new_profile = ImagerProfile(user=instance)
        new_profile.save()

from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from imagerprofile.models import ImagerProfile


@receiver(post_save, sender=User)
def add_profile(sender, **kwargs):
    if kwargs['created']:
        obj = kwargs.get('instance')
        new_profile = ImagerProfile(user=obj)
        new_profile.save()

Fix instance handling in profile handler
Fix instance handling in profile handler

  from django.db.models.signals import post_save
  from django.dispatch import receiver
  from django.contrib.auth.models import User
  from imagerprofile.models import ImagerProfile
  
  
  @receiver(post_save, sender=User)
- def add_profile(sender, instance, **kwargs):
+ def add_profile(sender, **kwargs):
      if kwargs['created']:
+         obj = kwargs.get('instance')
-         new_profile = ImagerProfile(user=instance)
+         new_profile = ImagerProfile(user=obj)
          new_profile.save()
  
Fix instance handling in profile handler
## Code Before:
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from imagerprofile.models import ImagerProfile


@receiver(post_save, sender=User)
def add_profile(sender, instance, **kwargs):
    if kwargs['created']:
        new_profile = ImagerProfile(user=instance)
        new_profile.save()

## Instruction:
Fix instance handling in profile handler
## Code After:
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from imagerprofile.models import ImagerProfile


@receiver(post_save, sender=User)
def add_profile(sender, **kwargs):
    if kwargs['created']:
        obj = kwargs.get('instance')
        new_profile = ImagerProfile(user=obj)
        new_profile.save()
