I am trying to deploy a django application on a virtual server running ubuntu 16.04.
python manage.py makemigrations
leads to the following traceback, after some models and fields have been created:
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "/home/sysadmin/.virtualenvs/django/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/sysadmin/.virtualenvs/django/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/sysadmin/.virtualenvs/django/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/sysadmin/.virtualenvs/django/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/sysadmin/.virtualenvs/django/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 150, in handle
self.write_migration_files(changes)
File "/home/sysadmin/.virtualenvs/django/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 179, in write_migration_files
with open(writer.path, "wb") as fh:
IOError: [Errno 13] Permission denied: u'/home/sysadmin/public_html/aegee-stuttgart.org/aegeewww/migrations/0001_initial.py'
I also tried:
sudo python manage.py makemigrations
But since I am using a virtual environment, I get the following error, since django is not installed system wide:
ImportError: No module named django.core.management
How can I fix this error? The python path is recognized correctly and django is obviously installed in the venv.
How do I have to set the permissions for the user?
Thanks!
You need grant access for user to migrations folder:
sudo chown <your_username> <path_to_migrations_folder>
The directory should be owned by the current user to make changes to it.
for instant solution use:
try: sudo python3 manage.py makemigrations
also try changing the chown by
sudo chown owner_name foldername(or)dir
ex:sudo chown ubuntu db.sqlite3
in the corresponding directory.
check by using:ls -la
shows the permissions of files in current directory.
if nothing works out try changing read/write permissions of the file:sudo chmod permission_no dir_name
permission_no 6644 or 777 both works fine.
ex: sudo chmod 777 db.sqlite3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With