Wednesday, December 29, 2010

Re: automatic addition of several ForeignKeys to model

Thanks.

The thing which i wanted must be done in forms. It is not for models
and database.

I mean there must be function in views.py which checks if some item
already exists in database and add information about this item
(item.pk) to another synonim item.

On 27 Gruo, 21:15, Emmanuel Mayssat <emays...@gmail.com> wrote:
> 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.statk...@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 athttp://groups.google.com/group/django-users?hl=en.- Slėpti cituojamą tekstą -
>
> - Rodyti cituojamą tekstą -

--
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