[Django model] Undefined variable from import: DoesNotExist
Brought to you by:
fabioz
[Remark: It's not yet possible to select 1.5.0 as "Group" for bug reports. This report is based on Pydev 1.5.0 (Eclipse Galileo)]
Django equips its model classes dynamically (using setattr) with the exceptions 'DoesNotExist' and 'MultipleObjectsReturned' (see django/db/models/base.py: ModelBase.__new__). This leads to Pydev marking the following occurrence of the exception as an error and not showing the exceptions in code completion:
from django.db import models
class SimpleModel(models.Model):
pass
raise SimpleModel.DoesNotExist
The exact error message is "Undefined variable from import: DoesNotExist".
I have the same problem with TurboGears (SQLAlchemy) model classes. All members which are dynamically added give this "undefined variable" errors. Very annoying, because these classes are used a lot in TurboGears/SQLAlchemy.