Hi,

I have the following problem:
I have models.py with the following class:

class Section(Feed):
    parent = models.ManyToManyField('self', blank=True, null=True)
    depth = models.IntegerField(editable=False)
    def save(self):
        self.depth = 1
        if self.parent:
            self.depth = self.parent.depth + 1
        return super(Section, self).save()
    def __unicode__(self):
        return "Section_%s" %(self.title)

and admin.py with the following classes:

class SectionInline(admin.TabularInline):
    model = Section
    extra = 2
    verbose_name_plural = "Sub Sections"

class SectionAdmin(admin.ModelAdmin):
    inlines = [
        SectionInline, ItemInline
    ]


When I try to save new Section from the admin page, I get the
following error:

'Section' instance needs to have a primary key value before a many-to-
many relationship can be used.

There are 2 things that I don't understand:

1.) Why am I getting this error, if my ManyToMany relation is optional
2.) I tried many things including defining id of the Section with
AutoField but still without luck.

Does anyone have an idea what is my problem/mistake here?

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

Reply via email to