Multiple databases with same model names causing get errors
|Reported by:||anonymous||Owned by:||Michael Radziej|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Code that causes the problem:
emplid = models.CharField(max_length=15,primary_key=True)
... (other fields deleted)
app_label = u'everyone'
db_tablespace = u'everyone'
db_table = u'people_names'
managed = False
emplid = models.CharField(max_length=11, db_column='emplid', primary_key=True
) ... (other fields deleted)
app_label = u'commons'
db_tablespace = u'people'
db_table = u'person'
I tried (view.py):
person = everyone.Person.objects.get(pk=emplid)
except everyone.Person.DoesNotExist: # person not found by "get"
do some stuff
django complains in the 'except' : global name 'everyone' is not defined.
Apparently django does not support multi-database models in the same way as the default database. There is a work-around, but this behaviour then is inconsistent with default database models. Don't know if this is due to model names being the same.