Вопрос

In django I had a profile of the type

from django.contrib.auth.models import User

class Profile(models.Model):
    user = models.OneToOneField(User)

and since I wanted to create such a profile whenever a User is created, I hooked up into the User creation signal of django-registration:

from django.dispatch import receiver
from registration.signals import user_registered
from models import Profile

@receiver(user_registered)
def handle_user_registered(sender, **kwargs):
    user = kwargs.get('user')
    profile = Profile(user=user)
    profile.save()

Now with mezzanine, I'm using mezzanine.accounts instead of django-registration. How do I do the same thing? As far as I can tell right now, they don't define signals...

Это было полезно?

Решение

Turns out that mezzanine already does this automatically. You can find the receiver in mezzanine/accounts/models.py.

Of course, for this to work, you have to list mezzanine.accounts in INSTALLED_APPS.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top