Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyDev + Django - undefined variables from import

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...

like image 265
TyrantWave Avatar asked Jul 25 '14 08:07

TyrantWave


1 Answers

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).

like image 70
Zags Avatar answered Nov 01 '22 17:11

Zags