Blueice
Blueice

Reputation: 143

Django sqlite database not gettitng created in local machine and in remote getting Secret key Error

I am having the below settings for database in settings/base.py. The behaviour is different in both my local Mac OS X and in ubuntu for the same code.

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

In local OS X machine, i experience the below error:

  File "/Users/user/.virtualenvs/p_dev/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 207, in get_new_connection
    conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file

In ubuntu server, where i try to host it for test, it shows below error.

  File "/home/user/.virtualenvs/p_live/lib/python3.4/site-packages/django/conf/__init__.py", line 120, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Full error code is in pastebin here: http://pastebin.com/ERw0cJPm

Kindly help here. I checked the database folder both in local and server, this is not getting created.

Upvotes: 0

Views: 232

Answers (1)

Siva Arunachalam
Siva Arunachalam

Reputation: 7750

OSX Issue:

Make sure that your django server process has access to write on the configured location.

Ubuntu Issue:

The manage.py module can't load the settings file configured in it. You can try after explicitly adding the --settings=<project_name>.settings.py

(p_live) user@ip-xx-xx-xx-xxx:~/sites/site.com/source$ python manage.py runserver --settings=<project_name>.settings.py

<project_name> = Pacakage name (or Django project name) where settings.py exists.

Upvotes: 1

Related Questions