zeliboba skrev: > actually, I understand how it works, it seems to be a bug anyway. > consider this: > > 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() > """ > id = models.CharField(maxlength=5, primary_key=True) > title = models.CharField(maxlength=50) > authors = models.ManyToManyField(Author) > > I specified primary_key explicitly and it works without saving before > adding Author. Yes, this is a bug. This should definitely raise an error. I guess the reason it doesn't is that char fields (like your primary key) are automatically populated with an empty string. Still, I would expect the .add(a) to gfive a foreign key violation. Does your backend support foreign keys?
Also, if you understand what is happening, why aren't you just doing what Leo is suggesting, rather than adding additional fields? Nis --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---