Take the 2-minute tour ×

I am developing a web app with django 1.2.4, but I am having a problem with the Site model. I try:

from django.contrib.sites.models import Site
if Site._meta.installed:

I am getting the error undefined variable from import: _meta in the if statement, any help?

share|improve this question
Where are you running that? Devserver? –  Lycha Nov 3 '11 at 23:51
Works in 1.3.0. I know that doesn't answer your question, but maybe take a look at the change logs. Or, just look in the Site class. –  sberry Nov 3 '11 at 23:52
@Lycha I am running in localhost for now –  juankysmith Nov 4 '11 at 6:42
By adding an "OK!" to your title, did you mean to imply that you've solved the problem? If so, it might be better simply delete your question, or if you think others may benefit from your solution, post and answer with the details and mark it as the answer. –  Shawn Chin Nov 7 '11 at 9:44
No, it was an error: I unintentionally pressed Enter. Can you help me? –  juankysmith Nov 7 '11 at 9:47
show 3 more comments

1 Answer

up vote 2 down vote accepted

Unless you've fiddled with the django source, there really should be any problems with the Sites._meta.installed variable. _meta.installed is assigned from within the metaclass of all models (using contribute_to_class()) so it would affect ALL models if the code were broken.

A quick search for relevant tickets does not reveal such a problem for that version (or any other version) of django.

Are you by any chances running django via pydev? If so, perhaps this post is relevant: How do I fix PyDev "Undefined variable from import" errors?

That's of course a wild speculation on my part. If you can post a Trackback of your error, we might be able to get a better insight into your problem.

Response to comments:

"I get the error in the IDE (apatana Studio 3)"

Aptana uses PyDev and so will exhibit the same problem. Here's a possible fix taken from this blog post:

  1. Open up Aptana Studio
  2. Open Window > Preferences > PyDev > Editor > Code Analysis
  3. Select the “Undefined” tab
  4. Add DoesNotExist at the end of the “Consider the following names as globals” list
  5. Apply and restart
share|improve this answer
add comment

Your Answer


