PyDev + Django - undefined variables from import
Asked Answered
C

1

8

Specifically, any querysets are causing this:

users = User.objects.all().order_by('user_group__user_group_description', 'user_name')

all() is saying Undefined variable from import

This is on any queryset in my views - and yet the server's running fine. I've added django to forced builtins, I've reinstalled django, I've even reinstalled pydev, it's adamant this variable doesn't exist, but the server'll run fine anyway.

To make things more annoying, it was working fine recently and just stopped working - no changes had been made to the code.

I've got no idea what to try.

Edit: So I've got a fix, but I'm not sure why this works.
Downgrading to Django 1.6.5 then reupgrading to 1.7, rebuilding the python interpreter, fixed this. Not ideal though as I have files from 1.6.5 on my computer and it's recommended to remove them...

Comedian answered 25/7, 2014 at 8:11 Comment(0)
P
1

I had the exact same problem. It started when I upgraded Django from 1.6 to 1.7

The fix for me was downgrading to 1.6. You can have 1.6 in your system-wide python environment and use 1.7 in virtual environments and Eclipse/PyDev will work fine (barring knowing about Django 1.7 functions).

Poirer answered 31/10, 2014 at 22:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.