开发者

Noob can't get Aptana to run a Django server

开发者 https://www.devze.com 2023-04-06 01:41 出处:网络
I\'m lost and confused. Following a guide, I managed to get a Django server runni开发者_如何转开发ng by going to run -> cmd, cd to the project directory, and typing python manage.py runserver.That wor

I'm lost and confused. Following a guide, I managed to get a Django server runni开发者_如何转开发ng by going to run -> cmd, cd to the project directory, and typing python manage.py runserver. That works fine.

I'm trying to get the Aptana server running so that I can debug code with breakpoints. So I right-clicked the project in Aptana and select Run as -> PyDev Django. But then I get the error message "no such table: django_session."

Why does the server work from the command line but not from Aptana? I need to get it to work from Aptana so I can debug.


You should be able to right click a project with a Django configuration and choose "run as > Django".

See: http://pydev.org/manual_adv_django.html for details on configuring Django.


The problem happens because the default "Run configuration" generated by Pydev/Eclipse points to the location of the workspace, rather than to your project.

To fix this, edit the Run Configuration (right click on the project -> Run as -> Run configurations). Change the setting Arguments -> Working Directory from Other (${workspace_loc:}) to Default (${project_loc:/selected project name})

This is strange behaviour, since the right option is called default, but not automatically used when the cfg is created.


I will still use the command prompt to run the server. Things get tricky on me with Aptana running python processes, because they tend to remain opened in the background and in the case of Django server will keep the previous port used (default I believe to be :8080) in case you want to restart.


I finally fixed it! The guide I was following had told me to do the wrong thing. To any googlers with this problem:

Go to settings.py. Find where it says DATABASES. Under NAME, the guide had told me to type a relative path to the database file. In fact, it needs a full path to the file. For example, 'C:\\Documents and Settings\\whatever\\My Documents\\Aptana Studio 3 Workspace\\app_name\\src\\sqlite.db'.


I had the same problem but found that it was a problem with, I believe, Aptana's current working directory when it is running your app. From what I can gather Aptana seems to set the CWD to be it's own workspace root location (in my case that is C:\Users\Sean\Documents\Aptana Studio 3 Workspace)

I fixed it by doing either of the following:

  • Move the .db file into the workspace root (which was up one directory level for me)

or

  • supply the relative path from the workspace root directory to your .db file e.g. 'appName/test.db'

In either case this will stop the application from working at the command prompt because your CWD will be the same folder that manage.py is found.

If it is a problem and you want to use the command prompt you can cd into your workspace root and then call manage.py from there (e.g. python myapp\manage.py runserver).


I fixed it by doing either of the following:

  • Move the .db file into the workspace root (which was up one directory level for me)

or

  • supply the relative path from the workspace root directory to your .db file e.g. 'appName/test.db'

Também resolvi meu problema asism. Obrigado por ter ajudado. (I solved my problem by the same way. Thanks for your help.)

0

精彩评论

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

关注公众号