Sunday, November 15, 2009

Re: ManyToOne to auth.models.User

On 09-11-15 7:00 AM, TiNo wrote:
> On Sun, Nov 15, 2009 at 09:31, Dennis Kaarsemaker
> <dennis@kaarsemaker.net <mailto:dennis@kaarsemaker.net>> wrote:
>
> On za, 2009-11-14 at 15:53 -0800, TiNo wrote:
>
> > In my apps, Users of the app participate in a certain Year. I would
> > like a Year to continue a ManyToOne relationship with a User. As
> > creating a ForeignKey on a User is not possible, what would be the
> > best way to do this? I don't need a full-blown profile for a user,
> > just this connection with a year.
>
> Creating a ForeignKey to django.contrib.auth.models.User is definitely
> possible.
>
>
> Of course. But having each User have a ForeignKey to a Year is not..
> Which is what I want.

You could write your own user model. But if you don't want to do that,
make a profile and put the year on that. Or use model inheritance. Or
make a foreign key on another model to the User object (as Dennis noted)
and then use reverse lookups.

Personally I would recommend making a profile, you'll likely be adding
more to it.
--
Andy McKay, @clearwind
Training: http://clearwind.ca/training/

--

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate