Forums

eror in manage.py

I didn't change the manage.py file. But there is a red cross in front of line 14. On the command "python manage.py migrate" there is also a problem. How to solve this in the manage.py?

> #!/usr/bin/env python import os import sys
> 
> if __name__ == '__main__':
>     os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
>     try:
>         from django.core.management import execute_from_command_line
>     except ImportError as exc:
>         raise ImportError(
>             "Couldn't import Django. Are you sure it's installed and "
>             "available on your PYTHONPATH environment variable? Did you "
>             "forget to activate a virtual environment?"
>         ) from exc
>     execute_from_command_line(sys.argv)

I think you can ignore the red "X" in the editor; because of the "hashbang" in the first line, our editor is trying to syntax-check it using Python 2.7, but that manage.py file was generated using Python 3.x -- and the from exc is not valid Python 2.7. It will run fine, so long as you use the correct Python version.

To do that, you need to activate your virtualenv before running it -- you can either start a Bash console inside your virtualenv from the link on the "Web" tab (in the "Virtualenv" section) or you can start a regular Bash console, then run workon yourvirtualenvname (replacing "yourvirtualenvname" with the actual name of the virtualenv) before running python manage.py migrate.

I'm still having this error after python3 manage.py migrate:

Applying myapp.0001_initial...Traceback (most recent call last):
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/backends/base/base.py", line 239, in _commit
    return self.connection.commit()
sqlite3.OperationalError: disk I/O error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 203, in handle
    fake_initial=fake_initial,
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/backends/sqlite3/schema.py", line 27, in __exit__
    super().__exit__(exc_type, exc_value, traceback)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 108, in __exit__
    self.atomic.__exit__(exc_type, exc_value, traceback)
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/transaction.py", line 212, in __exit__
    connection.commit()
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/backends/base/base.py", line 261, in commit
    self._commit()
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/backends/base/base.py", line 239, in _commit
    return self.connection.commit()
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/bloem/.virtualenvs/django2/lib/python3.6/site-packages/django/db/backends/base/base.py", line 239, in _commit
    return self.connection.commit()
django.db.utils.OperationalError: disk I/O error

What are your Django database settings?

What do you mean? I'm not using mysql and try to use sqlite3. In settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

There is this file db.sqlite3 . I cannot open this file.

You have run out of disk space (storage) on your account, so you can't write to your database.