What I do to create a view that includes both -- the User and the
UserProfile -- is following the documentation of forms and
manipulators
http://www.djangoproject.com/documentation/forms/
and writing something like this:

def add_profile(request):
    from datetime import datetime
    user_manipulator = User.AddManipulator()
    profile_manipulator = UserProfile.AddManipulator()
    if request.POST:
        new_user_data = request.POST.copy()
        new_profile_data = request.POST.copy()
        new_profile_data.update(request.FILES) # if you are using any
file uploads...
        now = datetime.now()
        new_user_data['date_joined_date'] = now.strftime("%Y-%m-%d")
        new_user_data['date_joined_time'] = now.strftime("%H:%M:%S")
        new_user_data['last_login_date'] = "1900-01-01"
        new_user_data['last_login_time'] = "00:00:00"
        new_user_data['is_active'] = 'on'
        new_user_data['is_superuser'] = 'off'
        new_user_data['is_staff'] = 'off'
        new_profile_data['user'] = 1 # temporary, just for validation
        user_errors = user_manipulator.get_validation_errors(new_user_data)
        profile_errors =
profile_manipulator.get_validation_errors(new_profile_data)
        if not user_errors and not profile_errors:
            user_manipulator.do_html2python(new_user_data)
            user = user_manipulator.save(new_user_data)
            #user = User.objects.create_user(
            #    new_user_data['username'],
            #    new_user_data['email'],
            #    new_user_data['password']
            #)
            user.set_password(new_user_data['password'])
            user.save()

            new_profile_data['user'] = user.id
            profile_manipulator.do_html2python(new_profile_data)
            profile = profile_manipulator.save(new_profile_data)
            ...

I hope this will be helpful to you.

Good luck!
Aidas Bendoraitis [aka Archatas]

On 7/17/06, spako <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> i'm using django's built in User for web registered users, to add extra
> fields to these users i've created a UserProfile model and linked it to
> User using a OneToOneField.
>
> Now when someone goes to the site to register I want them to see a form
> with fields from User and some from UserProfile. I'm looking into using
> custom/generic manipulators to do this, i'd like to know if there is a
> certain method of doing this or if anyone else has done this before?
>
>
> >
>

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

Reply via email to