I'm using the 'one to one' method of creating a user profile which
extends django's built-in user model. This is a workaround suggested by
James Bennett on his b-list blog, and I think several other people are
using this or something similar.

My problem is that I have a database I am importing. It contains user
info which I need to insert into both the built-in user, and my
userProfile models.

This is how I am attacking it right now:
1- add new user, where 'u' is an object read from the old data:
newuser = User.objects.create_user(u.uname, u.email, u.pword)

2- add the extra user info to the userProfile model using the "last
inserted id"
newprofile = UserProfile(
    user = newuser.id,
    office = u.office,
)

Unfortunately, I get an error calling "Invalid Value", but aren't they
both IDs of the same type? This is what it says:
Invalid value: 'user' should be a <class
'django.contrib.auth.models.User'> instance, not a <type 'long'>

Seems like this should work, and I've seen examples using a similar
approach, but this has stumped me for a few weeks now and I'm getting
tired of looking at it. :-)


--~--~---------~--~----~------------~-------~--~----~
 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