Search code examples
djangodjango-south

django south: problems with path to django


The problem causes this error when I try to use south:

$ python manage.py schemamigration
You must provide an app to create a migration for.
$ python manage.py schemamigration myapp --initial
OSError: [Errno 13] Permission denied: '../myapp/migrations'
$ sudo python manage.py schemamigration myapp --initial
ImportError: No module named django.core.management
$ python
>>> import south
>>> import django.core.management
>>> south.__file__
'/home/mydev/venv/lib/python2.7/site-packages/south/__init__.pyc'
>>> django.__file__
'/home/mydev/venv/lib/python2.7/site-packages/django/__init__.pyc'

It seems to me that manage.py schemamigration generates an error message that appears to be returned by schemamigration. But schemamigration and other south commands cannot find django once they are called.

'/home/mydev/venv/lib/python2.7/site-packages/' is on my sys.path. The /south folder is a sim link to the actual south package which is in a /dist-packages folder. I did put a sim link in the actual /south folder back to the the django package, but that didn't solve anything.

What could be wrong?


Solution

  • The problem is due to permissions and use of virtualenv. You got the 'permission denied' error as your current user does not have write permissions for this project.

    You can change the permissions for the entire project and make you current user as the owner of all files and folders in the project

    sudo chown -R <username>:<username> <project_folder>
    

    When you tried running migration using sudo it was not able to find django package as it lies in the virtualenv which has been activated by normal user. I guess these steps should solve this incase you don't want to change the permissions.

    sudo -i
    source /<virtualenv_path>/bin/activate
    

    This should activate the virtualenv for sudo and now you'll be able to access all packages in the virtualenv

    I think you should go the permissions way