I'm no guru, Im  stuck  also with some many-to-many features.

1.- why whould you need a  3rd  table if you are not using attributes
in the relationship? (Variant).
2.- have you tried to add an models.AutoField(primary=True) to your
model Variant ? I knew django does that if no is specified in order to
preserve the 3rd normal form, but it would be a first aproach.

Hope this helped out a little.

Regards
ndarkduck

On Oct 30, 7:40 am, chris <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I am still pretty new to django and just trying to figure out how it
> is all supposed to work.
>
> I have the following models:
>
> *models.py:
>
> class Char(models.Model):
>     char = models.CharField(max_length=10)
>     variants = models.ManyToManyField("self", symmetrical=False,
> through="Variant", related_name="varchars", blank=True, null=True)
>
> class Variant(models.Model):
>      char = models.ForeignKey(Char)
>      variant = models.ForeignKey(Char, related_name="vars")
>
> *admin.py:
>
> class CharVarInline(admin.StackedInline):
>       model = Variant
>       fk_name = "char"
>       raw_id_fields=("variant", "char",)
>       extra = 1
>
> class CharAdmin(admin.ModelAdmin):
>     inlines = (CharVarInline,)
>
> This causes the variants part to be displayed with a char record in
> admin.  I also get a check-box there, which can be checked to delete
> the inlined related recorded.   However, when I try to used this to
> delete the record and click save, the following error occurs:
>
> ValueError at /admin/chardb/char/70524/
>
> 'Variant' instance needs to have a primary key value before a many-to-
> many relationship can be used.
>
> Apparently, something is going wrong with the deletion, which lets
> part of the record hang in empty air.  But I have no idea where to
> look or how to fix this.  Does anybody has any idea?
>
> Any help appreciated,
>
> Chris
--~--~---------~--~----~------------~-------~--~----~
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