Monday, December 27, 2010

Re: automatic addition of several ForeignKeys to model

yes and no ;-)
I am not sure I understand clearly, but I believe you want to have
let's say 2 word1 links in word2
For that you need yo use the related_name as otherwise in word1,
django tries to create 2 word2 fields (which result in an error)

149 class Mentorship(models.Model):
154 mentee = models.ForeignKey(User, related_name='menteeship_set')
155 mentor = models.ForeignKey(User, related_name='mentorship_set')

On Mon, Dec 27, 2010 at 10:00 AM, gintare <g.statkute@gmail.com> wrote:
> Hello,
>
> I would like to add ForeignKey which would ass many items to class as
> much i append-create-give.
>
>
> class word1(models.Model):
>    item=models.CharField(blank=True)
>
> class word2(models.Model):
>    itemSynonims=models.ForeignKey(word1)
>
> i would like to add several word1 to the class word2.
>
> Is there a way to create a pointer of type ForeignKey(word1), which
> would
> let to add many word1, word1, word1 to the same itemSynonims.
>
> regards
>
>
>
> --
> 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=en.
>
>

--
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=en.

No comments:

Post a Comment