tags:

views:

51

answers:

2

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 folder, 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

+4  A: 

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.

Olivier
+1 - if you can't move your entire project without breaking anything, you're doing it wrong.
Dominic Rodger
+1 Changed all my hard coded path! thanks, though it didn't fix the problem, PYTHONPATH was the problem as Hans has stated. Thanks.
gath
+2  A: 

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.

Hans