Primary Key for auth_user is User.__str__() ??

11 views
Skip to first unread message

gkelly

unread,
Sep 26, 2006, 12:24:22 AM9/26/06
to Django users
I have the following model and view:

http://pastebin.ca/182428

If I manually edit
/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/auth/models.py
and change User.__str__(self) to return a string like
'TEST'+self.username, then 'testuser' above will become 'TESTtestuser'.

So it appears pk_val is user.username and not user.id?? What's going on
here?

gkelly

unread,
Sep 26, 2006, 4:40:22 PM9/26/06
to Django users
bump. please help. this is driving me nuts.

Alan Green

unread,
Sep 26, 2006, 9:17:39 PM9/26/06
to django...@googlegroups.com

Not sure if this is your problem, but the documentation for
OneToOneFields says, "we don't recommend you use them."

http://www.djangoproject.com/documentation/model_api/#one-to-one-relationships

One of my applications has a UserProfile object. After trying
OneToOneFields and not quite getting the results I wanted, I settled
on using a ForeignKey instead of a OneToOne, and it works.

Hope that helps,

Alan.

>
>
> >
>


--
Alan Green
al...@bright-green.com - http://bright-green.com

gkelly

unread,
Sep 26, 2006, 10:42:54 PM9/26/06
to Django users
Alan,

I've tried using ForeignKey also. It gives me different problems. See
http://groups.google.com/group/django-users/browse_thread/thread/ad493aadb30b3cde/

I'd love to get some more input.

Thanks,
Grant

Reply all
Reply to author
Forward
0 new messages