Thanks Alex, symmetrical argument solved the problem. You saved me a
lot of time!

On 4 апр, 13:28, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> a) It should be related to "self" not 'Task'.
>
> b) Add the kwarg: symmetrical=False, by default this is true and it
> makes it so the relationship is assumed to go both ways.
>
> On Apr 4, 2:22 am, Dmitriy Sodrianov <[EMAIL PROTECTED]> wrote:
>
> > Hi to all!
>
> > I have a model
>
> > class Task(models.Model):
> >     title = models.CharField(max_length = 250)
> >     subtasks = models.ManyToManyField('Task', null=True, blank=True)
>
> > The problem is that when I add subtask to task, task is also added to
> > subtask, look at the following code to see what I mean.
>
> > >>> subtask = Task.objects.create(title='subtask')
> > >>> task = Task.objects.create(title='task')
> > >>> task.subtasks.add(subtask)
> > >>> task.subtasks.all()
> > [<Task: subtask>]
> > >>> subtask.subtasks.all()
>
> > [<Task: task>]
>
> > But the thing I want it only to add subtask to task, not vice versa.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to