hi again

I'm writing custom scientific reference management application and
encountered a strange thing, cannot understand if it is bug or
feature, see example models.py:

from django.db import models

class Author(models.Model):
    name = models.CharField(maxlength=50)

class Reference(models.Model):
    """
    >>> a = Author(name='some name')
    >>> a.save()
    >>> r = Reference(title='some title')
    >>> r.authors.add(a)
    >>> r.save()
    """
    title = models.CharField(maxlength=50)
    authors = models.ManyToManyField(Author)

the above doctest failed with message "ValueError: <...> instance
needs to have a primary key value before a many-to-many relationship
can be used." ok, I gave it (add one more field to Reference, though
it is default):

    id = models.AutoField(primary_key=True)

and it does't work! ok, try nondefault:

    idid = models.IntegerField(primary_key=True)

again doesn't work... the only way to make it work is to modify title
field by adding primary_key=True (or crate a dummy CharField since I
do not want to have primary key on title)

I tried django-0.96 on Gentoo


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