You could also have a common parent class for Robot and User, and use that
as your foreign key type. Which type is referenced would be your
determination of user type.

On Sun, Oct 26, 2008 at 6:19 AM, CooLMaN <[EMAIL PROTECTED]> wrote:

>
> Hello,
>
> I have an application with a model similar to the following:
> class Relations(models.Model):
>        user1 = models.ForeignKey(User, related_name='relations_user1_set',
> editable=False)
>        user2 = models.ForeignKey(User, related_name='relations_user2_set',
> editable=False)
>        userType = models.PositiveSmallIntegerField(max_length=1,
> editable=False, choices=( ('0', 'user'), ('0', robot) ))
>
> Ok, so basically what I need this to do is that in case that the
> userType is 1-robot it'll be a ForeignKey to Robot and not to User.
>
> I'm assuming this is not possible with the current ORM implementation,
> but I would be glad to hear I'm wrong.
>
> Any suggestions? (this table serves the same purpose, and I'll most
> likely always grab both robots and users so having another table for
> each type is redundant and will be a problem if I append any more
> choices in the future).
>
>
> Thank you!
> Gil
>
> >
>


-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing:
http://www.twitter.com/ironfroggy

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to