开发者

How to copy a django project from one folder location to another?

Am using eclipse+pydev to build my django apps. I created a new workspace, built a new pydev project then created an empty folder in the new pydev project. In that empty folder i imported my old django application. Eclipse copied all the files & folders from my old django location to the new workspace.

I made the necessary changes in the settings.py on my new location, pointed the templates & data location to my new location workspace folder.

But when i run manage.py runserver from the new location workspace fol开发者_开发百科der, django seems to point to my old folder location. All the html templates seems to point to the old location.

How can i make django execute stuff in my new location?

What am i missing?

Edit: When i run the server inside eclipse, everything seems to be OK! funny.

Gath


There is no reason why you could not move your django folder, except for the presence of some absolute file path that you added. You should never have an absolute path in your project.

You should use the following trick in the settings.py file, as explained in the django wiki:

import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))

# then for each subdirectory:
SOME_DIR = os.path.join(BASE_DIR, 'my_dir')

Then you can move your whole project without ever changing a single character inside.


I agree that something seems odd. Not hardcoding your paths is of course the first place to start. One other possible cause of the error could be that you have added your original project/app to the PYTHONPATH and that it gets imported from there instead of the new place.

If being on a *NIX-system you could symlink your old location to the Eclipse workspace.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜