I have just installed South (0.7.3, python-2.6) and successfully completed the tutorial using the python interpreter. Meaning that I am able to create a model and migrate it without any errors, so South appears to be working fine in the python shell. I used an sqlite3 db for the tutorial.
我刚刚安装了South(0.7.3,python-2.6)并使用python解释器成功完成了教程。这意味着我能够创建一个模型并在没有任何错误的情况下进行迁移,因此South似乎在python shell中运行良好。我在教程中使用了sqlite3 db。
However, when I open my project in Eclipse, Eclipse does not recognize the functions associated with db in the migration folders: 0001_initial.py and 0002_auto__add_field_knight_dances_whenever_able.py files. I get the specific errors ( Undefined variable from import: add_column, create_table, delete_column, delete_table, send_create_signal)
但是,当我在Eclipse中打开项目时,Eclipse无法识别迁移文件夹中与db关联的功能:0001_initial.py和0002_auto__add_field_knight_dances_whenever_able.py文件。我得到了具体的错误(导入的未定义变量:add_column,create_table,delete_column,delete_table,send_create_signal)
Up until the South install, Eclipse has been working fine for creating django apps. I did point the PyDev interpreter to the south folder under site-packages (C:\python26\Lib\site-packages\south-0.7.3-py2.6.egg) (Other libraries there such as Django and django-picklefield work fine.)
直到南方安装,Eclipse一直在创建django应用程序。我确实将PyDev解释器指向site-packages下的南文件夹(C:\ python26 \ Lib \ site-packages \ south-0.7.3-py2.6.egg)(其他库如Django和django-picklefield工作精细。)
I ran a simple script from the eclipse project and from the python shell and both appear to have the same sys.path's
我从eclipse项目和python shell运行了一个简单的脚本,两者看起来都有相同的sys.path
Any tips on getting the Eclipse python interpreter happier?
有关让Eclipse python解释器更快乐的任何提示?
3 个解决方案
#1
4
One (far from ideal) solution is to put #@PydevCodeAnalysisIgnore
in all of your migrations. If you only have a few so far, you can do this manually. I had heaps, so I ran the following shell command, which will add the comment in as the second line of each file:
一个(远非理想的)解决方案是将#@ PydevCodeAnalysisIgnore放在所有迁移中。如果到目前为止只有几个,您可以手动执行此操作。我有堆,所以我运行了以下shell命令,它将添加注释作为每个文件的第二行:
find . | grep '^.\/[a-z]*\/migrations\/.*\.py$' | xargs -I FILE sed -i '
1 a\
#@PydevCodeAnalysisIgnore
' FILE
(Note: You should probably run find . | grep '^.\/[a-z]*\/migrations\/.*\.py$'
to see which files sed
will alter, before running the whole command. You can also run the whole command without the -i
flag to see the changes themselves.)
(注意:在运行整个命令之前,您应该运行find。| grep'^。\ / [az] * \ / migrations \ /.* \。py $'以查看sed将更改哪些文件。您还可以运行没有-i标志的整个命令可以自己查看更改。)
#2
19
Or, if you don't want to mess changing south source files or retouching all your migration files, you can consider south specific methods as globals in pydev code analysis. You can change this in:
或者,如果您不想混淆更改南方源文件或修饰所有迁移文件,可以将南方特定方法视为pydev代码分析中的全局方法。你可以改变这个:
Preferences > PyDev > Editor > Code Analysis > Undefined
My exceptions list are:
我的例外列表是:
_,tr,create_table,send_create_signal,delete_table,add_column,delete_column,alter_column,create_unique,create_index,delete_index,delete_unique,shorten_name,rename_column,execute
#3
3
Here's a workaround if you want to edit south/db/__init__.py
:
如果要编辑south / db / __ init__.py,这是一种解决方法:
--- db/__init__.py.original 2010-12-02 03:00:26.000000000 +1300
+++ db/__init__.py 2011-05-02 14:07:19.353636710 +1200
@@ -72,5 +72,9 @@
)
sys.exit(1)
-# Finally, to make old migrations work, keep 'db' around as the default database
+# Finally, to make old migrations work, keep 'db' around as the default
+# database. We're setting it explicitly to the generic operations first to
+# avoid pydev errors.
+from south.db import generic
+db = generic.DatabaseOperations(DEFAULT_DB_ALIAS)
db = dbs[DEFAULT_DB_ALIAS]
#1
4
One (far from ideal) solution is to put #@PydevCodeAnalysisIgnore
in all of your migrations. If you only have a few so far, you can do this manually. I had heaps, so I ran the following shell command, which will add the comment in as the second line of each file:
一个(远非理想的)解决方案是将#@ PydevCodeAnalysisIgnore放在所有迁移中。如果到目前为止只有几个,您可以手动执行此操作。我有堆,所以我运行了以下shell命令,它将添加注释作为每个文件的第二行:
find . | grep '^.\/[a-z]*\/migrations\/.*\.py$' | xargs -I FILE sed -i '
1 a\
#@PydevCodeAnalysisIgnore
' FILE
(Note: You should probably run find . | grep '^.\/[a-z]*\/migrations\/.*\.py$'
to see which files sed
will alter, before running the whole command. You can also run the whole command without the -i
flag to see the changes themselves.)
(注意:在运行整个命令之前,您应该运行find。| grep'^。\ / [az] * \ / migrations \ /.* \。py $'以查看sed将更改哪些文件。您还可以运行没有-i标志的整个命令可以自己查看更改。)
#2
19
Or, if you don't want to mess changing south source files or retouching all your migration files, you can consider south specific methods as globals in pydev code analysis. You can change this in:
或者,如果您不想混淆更改南方源文件或修饰所有迁移文件,可以将南方特定方法视为pydev代码分析中的全局方法。你可以改变这个:
Preferences > PyDev > Editor > Code Analysis > Undefined
My exceptions list are:
我的例外列表是:
_,tr,create_table,send_create_signal,delete_table,add_column,delete_column,alter_column,create_unique,create_index,delete_index,delete_unique,shorten_name,rename_column,execute
#3
3
Here's a workaround if you want to edit south/db/__init__.py
:
如果要编辑south / db / __ init__.py,这是一种解决方法:
--- db/__init__.py.original 2010-12-02 03:00:26.000000000 +1300
+++ db/__init__.py 2011-05-02 14:07:19.353636710 +1200
@@ -72,5 +72,9 @@
)
sys.exit(1)
-# Finally, to make old migrations work, keep 'db' around as the default database
+# Finally, to make old migrations work, keep 'db' around as the default
+# database. We're setting it explicitly to the generic operations first to
+# avoid pydev errors.
+from south.db import generic
+db = generic.DatabaseOperations(DEFAULT_DB_ALIAS)
db = dbs[DEFAULT_DB_ALIAS]