Hi,

Are you using AUTH_USER_MODEL?

I assume your logging is set up correctly?

Here's a snippet from one of my projects if you want to try out some 
similar code:

def user_save_handler(sender, **kwargs):
    user = kwargs['instance']
    try:
        user.userprofile
    except UserProfile.DoesNotExist:
        user_profile = UserProfile(user=user)
        user_profile.__dict__.update(user.__dict__)
        user_profile.save()
post_save.connect(user_save_handler, sender=User)

Collin

On Friday, January 16, 2015 at 1:14:09 PM UTC-5, Zach LeRoy wrote:
>
> I have a block of code that works fine in Django 1.6.10 but does not work 
> at all in Django 1.7.3.  I would expect my log statement to print every 
> time a Django User is created and this is the behavior in 1.6.10:
>
> import logging
>
> from django.contrib.auth.models import User
> from django.db import models
> from django.db.models.signals import post_save
> from django.dispatch import receiver
>
> log = logging.getLogger(__name__)
>
>
> class UserProfile(models.Model):
>     uuid = models.CharField(max_length=36)
>     user = models.OneToOneField(User)
>
>
> @receiver(post_save, sender=User)
> def create_user_profile(sender, instance, created, **kwargs):
>     """
>     When a new user is created, add a UserProfile
>     """
>     log.debug('received post save signal: {}'.format(instance))
>     if created:
>         UserProfile.objects.create(user=instance)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7815f84e-9042-4ef1-ac76-e160fefe5782%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to