Recent I was adding some django-profile code I found via Scot Hacker’s very helpful “django-profiles: The Missing Manual“.
When I added this bit of code for a custom form object:
def __init__(self, *args, **kwargs): super(ProfileForm, self).__init__(*args, **kwargs) try: self.fields['email'].initial = self.instance.user.email except User.DoesNotExist: pass
Aptana would call out “DoesNotExist” with the error: “Undefined variable from import: DoesNotExist”. Thanks to Google and the DjangoBot I learned that this is because “DoesNotExist” is added by the metaclass.
Here’s the fix
- Open up Aptana Studio (I’m v2.0.3 btw)
- Open Window > Preferences > PyDev > Editor > Code Analysis
- Select the “Undefined” tab
- Add DoesNotExist at the end of the “Consider the following names as globals” list
- Apply and restart
Error gone. In the immortal words of ubernostrum: “Bah. It’s not like metaclasses are *that* hard to statically figure out.” I’ll take your word for that, James.