Multiple databases with same model names causing get errors
|Reported by:||anonymous||Owned by:||mir|
|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.
Change History (3)
comment:1 Changed 5 years ago by anonymous
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 4 years ago by mir
- Easy pickings unset
- Owner changed from nobody to mir
- Status changed from new to assigned