#15781: Multiple databases with same model names causing get errors
-----------------------+------------------------------
Reporter: anonymous | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: Uncategorized
Version: 1.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 |
-----------------------+------------------------------
Code that causes the problem:
everyone.py:
class Person(models.Model):
emplid = models.CharField(max_length=15,primary_key=True)
... (other fields deleted)
class Meta:
app_label = u'everyone'
db_tablespace = u'everyone'
db_table = u'people_names'
managed = False
people.py:
class Person(models.Model):
emplid = models.CharField(max_length=11, db_column='emplid',
primary_key=True
) ... (other fields deleted)
class Meta:
app_label = u'commons'
db_tablespace = u'people'
db_table = u'person'
The 2nd people.Person model is my default db, so #1 is "everyone.Person"
and #2 is just "Person".
I tried (view.py):
try:
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.
--
Ticket URL: <http://code.djangoproject.com/ticket/15781>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.