2

Estou a um tempo tentando criar um usuário admin, mas ele sempre me retorna o erro abaixo. O que pode está acontecendo?

Estou utilizando as seguintes configurações:

Ubuntu Server 14.04.5 LTS, 
Python 3.4.3, 
Django 1.11. 

Qualquer ajuda será bem vinda.

Username (leave blank to use 'ubuntu'): ubuntu
Email address: [email protected]
Password:
Password (again):

Traceback (most recent call last): File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: attempt to write a readonly database self.UserModel._default_manager.db_manager(database).create_superuser(**user_data) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/contrib/auth/models.py", line 170, in create_superuser return self._create_user(username, email, password, **extra_fields) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/contrib/auth/models.py", line 153, in _create_user user.save(using=self._db) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/contrib/auth/base_user.py", line 80, in save super(AbstractBaseUser, self).save(*args, **kwargs) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/models/base.py", line 806, in save force_update=force_update, update_fields=update_fields) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/models/base.py", line 836, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/models/base.py", line 922, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/models/base.py", line 961, in _do_insert using=using, raw=raw) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/models/query.py", line 1060, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1099, in execute_sql cursor.execute(sql, params) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/backends/utils.py", line 80, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/utils.py", line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: attempt to write a readonly database (meusitedjango) ubuntu@ubuntuserver:/var/www/html/meusitedjango/meusitedjango$

1 Resposta 1

2

me parece, pelo trecho:

"/var/www/html/meusitedjango/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: attempt to write a readonly database 

Que o seu banco de dados está sendo usado em modo readyonly.

tente mudar o owner do diretório e do db para www-data

chown www-data:www-data /home/username/Django    
chown www-data:www-data /home/username/Django/db.sqlite  
1
  • Muito obrigado! Já tinha removido esse arquivo 0001_initial.py umas duas vezes. A solução foi remover o arquivo 0001_initial.py gerado pelo migrate e depois rodar os comandos abaixo. ./manage.py migrate python manage.py createsuperuser Commented 8/06/2017 às 14:36

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .