Problem: In a model that holds nothing else than a ManyToManyField, I
obviously have to introduce an unused field,
e.g.
 unused = CharField(maxlength=1)

Otherwise, some operations on the model (including save(), that I feel
to be important ;-)   ) raise an Exception (Stacktrace added below.)

++++++++++++++++++++++++++++++++++++

It can be reproduced with the ManyToMany-Example
http://www.djangoproject.com/documentation/models/many_to_many/
Just change the Article to have no "headline" anymore:

 class Article(meta.Model):
        #headline = meta.CharField(maxlength=100)
        publications = meta.ManyToManyField(Publication)

        def __repr__(self):
                return ""#self.headline

Now do the usual code from the example:
        # Create a couple of Publications.
        p1 = publications.Publication(id=None, title='The Python Journal')
        p1.save()
        p2 = publications.Publication(id=None, title='Science News')
        p2.save()

        # Create an Article.
        a1 = articles.Article(id=None, )   #, headline='Django lets you build
Web apps easily')
        a1.save()
        a1.save()

I can only save() the article a single time, but then nevermore.
The second save() will raise the exception (I added below).
Note that the Article is still created with an argument (id=None) but
it does not help.

Versions: Django rev.2536 (but same with older rev23xx),Python 2.3.

Regards.
 Ruben



Here's the Trace:
Traceback (most recent call last):
  File "/home/rr/dev/src/django-test/manytomany.py", line 98, in ?
    main()
  File "/home/rr/dev/src/django-test/manytomany.py", line 43, in main
    a1.save()
  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/meta/__init__.py",
line 1006, in method_save
    db_values + [pk_val])
  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/db/base.py",
line 10, in execute
    result = self.cursor.execute(sql, params)
  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/db/backends/mysql.py",
line 32, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 137,
in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line
33, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'WHERE `id`=1' at line 1")


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

Reply via email to