The trunk version of django-registration has been modified and it is
now even more simple to create a profile object.

Edit registration/urls.py :

# Import your profile object
from profile.models import Profile

# add the dict with your profile creation function
                       url(r'^register/$',
                           register,
 
{'profile_callback':Profile.objects.create},
                           name='registration_register'),


On Jun 24, 6:27 pm, Sam <[EMAIL PROTECTED]> wrote:
> This is how i use profile_callback with django-registration :
>
> 1. define the profile_callback function :
> # profile/models.py
>
> from django.db import models
> from django.contrib.auth.models import User
> from django.utils.translation import gettext_lazy as _
>
> class ProfileManager(models.Manager):
>     """
>     Custom manager for the ``Profile`` model.
>
>     """
>     def profile_callback(self, user):
>         """
>         Creates user profile while registering new user
>         registration/urls.py
>
>         """
>         new_profile = Profile.objects.create(user=user,)
>
> class Profile(models.Model):
>     user = models.ForeignKey(User, verbose_name=_('user'),
> unique=True)
>     # TODO : fill in profile fields
>
>     objects = ProfileManager()
>
> 2. Edit registration/urls.py :
>
> # Import your profile object
> from profile.models import Profile
>
> # add the dict with your profile creation function
>                        url(r'^register/$',
>                            register,
>                            {'profile_callback':
> Profile.objects.profile_callback},
>                            name='registration_register'),
>
> That's it.
>
> I'm still using 0.96 so i've added this on top of the registration/
> urls.py file to make it work:
> # TODO : remove when upgrading from 0.96
> def url(*args, **kwargs):
>     return args
>
> --http://django-fr.org/pour les francophones ! :P


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to