Reputation: 55
I was going through the tutorial on the Django website. I got this error while trying to create a Choice Object.
>>> q.choice_set.create(choice_text='Not much', votes=0)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/fields/related.py", line 714, in create
return super(RelatedManager, self.db_manager(db)).create(**kwargs)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/query.py", line 372, in create
obj.save(force_insert=True, using=self.db)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/base.py", line 589, in save
force_update=force_update, update_fields=update_fields)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/base.py", line 617, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/base.py", line 698, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/base.py", line 731, in _do_insert
using=using, raw=raw)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/query.py", line 921, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/models/sql/compiler.py", line 921, in execute_sql
cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/Django-1.7.8-py2.7.egg/django/db/backends/sqlite3/base.py", line 485, in execute
return Database.Cursor.execute(self, query, params)
OperationalError: attempt to write a readonly database
>>>
I dont understand what seems to be the problem. I tried changing the permissions for the "db.sqlite3" file to 777.
Thank you in advance.
Upvotes: 1
Views: 1243
Reputation: 1
If running on Mac OS X, make sure to prepend the command with sudo
(in the command line).
Upvotes: -1
Reputation: 558
You have to change permissions to the directory that database file is in too.
Upvotes: 2