开发者

Getting Django to work with Eclipse

I'm new to python and django but wanted to start following some tutorials. I installed python, then django, and then the pydev plugin for eclipse. I created a new django project and tried running it. In eclipse I set up a run configuration for manage.py with argument runserver and it said "Validating Models" but never said anything else.

I tried running via command line also but got some errors that I didn't see in eclipse:

C:\Users\JP\workspace\mysite\src\mysite>python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x02851E30>
Traceback (most recent call last):
  File "c:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 48, in inner_run
    self.validate(display_num_errors=True)
  File "c:\Python27\lib\site-packages\django\core\manage开发者_如何学Cment\base.py", line 245,
 in validate
    num_errors = get_validation_errors(s, app)
  File "c:\Python27\lib\site-packages\django\core\management\validation.py", lin
e 22, in get_validation_errors
    from django.db import models, connection
  File "c:\Python27\lib\site-packages\django\db\__init__.py", line 75, in <modul
e>
    connection = connections[DEFAULT_DB_ALIAS]
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 91, in __getitem
__
    backend = load_backend(db['ENGINE'])
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 32, in load_back
end
    return import_module('.base', backend_name)
  File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
    __import__(name)
  File "c:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 14
, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb

I assume it has something to do with my sql setup, but I'm not sure since it's a blank project and I haven't written any code yet. I'm more concerned with why nothing showed up in eclipse.


I'm just starting myself. Apparently there's a MySQLdb plugin (sorry if that's not the right term) that you need to use in addition to a standard MySQL install. This is so Python can communicate with MySQL.


It sounds like that you need to include the module in Eclipse System PYTHONPATH.

Go to Windows -> Preference -> Pydev -> Interpreter - Python.

After Select your desired python interpreters (if you have a virtual env), include your MySQL egg and all your other dependencies in your library.


It seems you don't have mysql installed. If you're only trying out django, you could use sqlite which ships with python. You can change the db backend in your settings.py file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜