1

I have a django app that uses django-authopenid as the sole registration method. I have registration in my installed apps, which django-authopenid uses. An ideal solution would allow me to run arbitrary code on the user object when they register. I can't directly modify the code for django-authopenis or registration.

Let me know if I need to add any more details.

Brigand
  • 84,529
  • 20
  • 165
  • 173

1 Answers1

2

On models.py you could bind the post_save signal:

from django.contrib.auth.models import User, Group
from django.db.models.signals import post_save


def default_group(sender, instance, created, **kwargs):
    if created:
        instance.groups.add(Group.objects.get(name='your default group name'))
post_save.connect(default_group, sender=User)

If in doubt, read the signals documentation.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
jpic
  • 32,891
  • 5
  • 112
  • 113
  • Thanks! I haven't used signals before, but this'll be very helpful in other parts of my app too. :-) – Brigand Feb 14 '13 at 20:45