﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5660	inconsistent behavior of explicit primary_key and ManyToManyField	zeliboba7@…	nobody	"In some cases explicit primary_key allows to use it for ManyToManyField relation before .save(), in others not. 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()
    """"""
    id = models.CharField(maxlength=5, primary_key=True)
    title = models.CharField(maxlength=50)
    authors = models.ManyToManyField(Author)
}}}
The doctest passed, since I specified primary_key explicitly and it works without r.save() before adding Author. but if you'll change id field to 
{{{
    id = models.AutoField(primary_key=True)
}}}
or to
{{{
    id = models.IntegerField(primary_key=True)
}}}
the doctest fails. the only cure is using r.save() before before r.authors.add(a) or 
r = Reference.objects.create(title='some title')
I tried both on django-0.96 and svn version with sqlite3 backend
"		closed	Uncategorized	dev		invalid			Unreviewed	0	0	0	0	0	0
