My schema:
class Component():
comp_id = models.CharField('Component ID', primary_key=True, db_column='comp_id')
path = models.CharField('Path')
def __unicode__(self):
return self.path
class Configuration():
config_id = Models.AutoField('Config ID', db_column='config_id', primary_key=True)
component = models.ForeignKey('Component', db_column='component')
org_id = models.Integer.Field('Org ID')
def __unicode__(self):
return "{} + {}".format(self.org_id, self.component)
class Result():
result_id = Models.AutoField('Result ID', db_column='result_id', primary_key=True)
config = models.ForeignKey('Configuration', db_column='config')
In the change form for Result, I expected the config foreign key to be represented by a dropdown. But instead the page won’t render and I get DatabaseError exception with message: “Attempt to initiate a new SQL Server operation with results pending.” What I think is happening, is that the Result.config dropdown is trying to resolve the unicode representations for the Configurations, but that means going one foreign key level deeper to resolve the unicode for the related Component and the database won’t allow it. Anyone see a way around this error?
It turns out my installation relies on a custom DB backend for MS SQL Server and I needed to edit it’s base.py file to include the following line in the DatabaseFeatures class: