﻿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
5139	Custom primary_key broken when saving	bjorn.kempen@…	nobody	"When you save a model instance with a custom primary_key, you can't retrieve the primary_key without getting the instance again first.
With a standard primary_key this works fine (like the documentation says)

Relevant code from my models
{{{
#!python
class XbtFiles(models.Model):
  fid = models.IntegerField(primary_key=True)
  info_hash = models.TextField(unique=True)

class Tag(models.Model):
    name = models.CharField(maxlength=128)
}}}

With standard primary_key it works fine
{{{
#!python
>>> t=Tag(name=""foo"")
>>> t.save()
>>> t.id
2L
}}}

With custom primary_key it is broken
{{{
#!python
>>> x=XbtFiles(info_hash=""this_field_is_unique"")
>>> x.save()
>>> x.info_hash
'this_field_is_unique'
>>> x.fid
>>> #huh nothing???
>>> y=XbtFiles.objects.get(info_hash=""this_field_is_unique"")
>>> x == y
False
>>> y.fid
10L
}}}
"		closed	Database layer (models, ORM)	dev		wontfix	primary_key save		Unreviewed	0	0	0	0	0	0
