in #1 I think you meant; user.save() staff = Staff() staff.user = user staff.save()
That might work. Otherwise, I'm not sire. Cheers, Dougal --- Dougal Matthews - @d0ugal http://www.dougalmatthews.com/ 2009/4/21 Joshua Partogi <joshua.j...@gmail.com> > > Darn, > > It's really difficult to reference a child instance to a parent if the > parent already exists in database with django :-( > > I tried this: > 1. > user.save() > staff = Staff() > staff = user > staff.save() > --> The data is not saved to the DB :-( > > 2. > user.save() > staff = Staff.objects.get(id=user.id) > staff.save() > > --> returned object already exist in DB error > > > Aarrrgh. > > Anybody got another trick for this? > > > On Apr 21, 1:25 am, Dougal Matthews <douga...@gmail.com> wrote: > > I think its as simple as; > > > > x = Staff() > > user_obj = x.user > > > > I found that by just printing out the result of dir(Staff()) ;) > > > > I think however, you want to add to add a subclass for a user that > > already exists. I'm not sure how you can do that, or if you can. The > > recommended guide to extending/adding to the user object is here; > http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-... > > > > You might find that way easier. > > > > Cheers, > > Dougal > > > > --- > > Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/ > > > > 2009/4/20 Joshua Partogi <joshua.j...@gmail.com>: > > > > > > > > > Dear all, > > > > > I have an inheritance model as such: > > > > > class User(models.Model) > > > > > class Staff(User) > > > > > Now I already have the instance of User inside view: > > > > > user = User.objects.create(name="Joe") > > > > > now how do I relate this user instance to the staff instance? > > > > > I tried looking in the documentation but can not find anything about > it. > > > > > Thank you very much in advance. > > > > > -- > > > If you can't believe in God the chances are your God is too small. > > > > > Read my blog:http://joshuajava.wordpress.com/ > > > Follow us on twitter:http://twitter.com/scrum8 > > > --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---