Error creating admin user Django 1.11

Asked

Viewed 95 times

2

I’ve been trying to create a user for a while admin, but it always returns me the error below. What can is happening?

I am using the following settings:

Ubuntu Server 14.04.5 LTS, 
Python 3.4.3, 
Django 1.11. 

Any help will be welcome.

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 self Return. _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 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 answer

2

I think, from the excerpt:

"/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 

That your database is being used in readyonly mode.

try changing the directory and db Owner to www-data

chown www-data:www-data /home/username/Django    
chown www-data:www-data /home/username/Django/db.sqlite  
  • Thank you very much! I had already removed this 0001_initial.py file a couple of times. The solution was to remove the 0001_initial.py file generated by migrate and then run the commands below. . /Manage.py migrate python Manage.py createsuperuser

Browser other questions tagged

You are not signed in. Login or sign up in order to post.