1

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?

Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
juankysmith
  • 11,839
  • 5
  • 37
  • 62

1 Answers1

2

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
Community
  • 1
  • 1
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
  • Tried this solution with LiClipse and still get the undefined variable from import: _meta error... at least now I know the issue is with the IDE! – user1255933 Oct 18 '22 at 03:39