﻿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 11523,ORM/MySQL backend doesn't set pk when Warning exception is raised,TomaszZielinski,nobody,"Link to the discussion: http://groups.google.com/group/django-users/browse_thread/thread/7c726fe6531abaaf Code: {{{ from MySQLdb import Warning as Warning from django.db import models import unittest class TestModel(models.Model): char_field = models.CharField(max_length=5) class Case1(unittest.TestCase): def test1(self): print ""Count 1:"", TestModel.objects.count() m = TestModel(char_field=""123456"") try: m.save() except Warning: print ""Count 2:"", TestModel.objects.count() print ""m.id="", m.id print ""all()[0].id="", TestModel.objects.all()[0].id }}} The above code prints: {{{ Count 1: 0 Count 2: 1 m.id= None all()[0].id= 1 }}} - which means to me that although m is saved to db, primary key is not set in m.pk after m.save(). If you look into newsgroups thread above, it seems that MySQLdb returns pk properly. ",Bug,new,"Database layer (models, ORM)",,Normal,,,,Accepted,0,0,0,0,0,0