Django OperationalError: unable to open database file


tuna@tuna-VirtualBox:~/Desktop/djangoprojects/mysite$ python manage.py syncdb
OperationalError: unable to open database file

if you get this error most probably you have typo inside settings.py file (NAME field), also arrange chmod 777 for sqllite.db file

DATABASES = {

‘default’: {
‘ENGINE’: ‘django.db.backends.sqlite3‘, # Add ‘postgresql_psycopg2’, ‘mysql’, ‘sqlite3’ or ‘oracle’.
‘NAME’: ‘/home/tuna/Desktop/djangodb/sqllite.db’, # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
‘USER’: ”,
‘PASSWORD’: ”,
‘HOST’: ”, # Empty for localhost through domain sockets or ‘127.0.0.1’ for localhost through TCP.
‘PORT’: ”, # Set to empty string for default.
}
}

after that you will see that the tables are created automatically;

tuna@tuna-VirtualBox:~/Desktop/djangoprojects/mysite$ python manage.py syncdb
Creating tables …
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django’s auth system, which means you don’t have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use ‘tuna’): tuna

How to learn django version


tuna@tuna-VirtualBox:~/Downloads/Django-1.5.1$ python
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import django
>>> print (django.get_version())

1.5.1
>>>

second way;

tuna@tuna-VirtualBox:~/Downloads/Django-1.5.1$ python -c “import django; print(django.get_version())”
1.5.1