Forums

no such table: django_site

I miss this error when I access the web, You can help me

http://hernandezpalo.pythonanywhere.com

I tried to register the absolute path in the config file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'default.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

just tried syncdb:

(ERP) 10:35 ~/django-erp (master)$ python manage.py syncdb                                                                                                                                                         
/home/hernandezpalo/.virtualenvs/ERP/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9
  warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)
Operations to perform:
  Synchronize unmigrated apps: staticfiles, formtools, messages
  Apply all migrations: core, redirects, menus, admin, sessions, sites, auth, notifications, contenttypes, pluggets
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

Just tried make migrations:

(ERP) 10:37 ~/django-erp (master)$ python manage.py makemigrations
Migrations for 'core':
  0004_auto_20180531_1037.py:
    - Alter field language on user

Just tried migration:

(ERP) 10:37 ~/django-erp (master)$ python manage.py migrate                                                                                                                                                        
Operations to perform:
  Synchronize unmigrated apps: staticfiles, formtools, messages
  Apply all migrations: core, redirects, menus, admin, sessions, sites, auth, notifications, contenttypes, pluggets
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying core.0004_auto_20180531_1037... OK

Reload Web

This the error on Web:

OperationalError at /users/login/
no such table: django_site
Request Method: GET
Request URL:    http://hernandezpalo.pythonanywhere.com/users/login/?next=/admin/
Django Version: 1.8
Exception Type: OperationalError
Exception Value:    
no such table: django_site
Exception Location: /home/hernandezpalo/.virtualenvs/ERP/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 318
Python Executable:  /usr/local/bin/uwsgi
Python Version: 2.7.6
Python Path:    
[u'/home/hernandezpalo/django-erp',
 '/var/www',
 '.',
 '',
 '/var/www',
 '/home/hernandezpalo/.virtualenvs/ERP/lib/python2.7',
 '/home/hernandezpalo/.virtualenvs/ERP/lib/python2.7/plat-x86_64-linux-gnu',
 '/home/hernandezpalo/.virtualenvs/ERP/lib/python2.7/lib-tk',
 '/home/hernandezpalo/.virtualenvs/ERP/lib/python2.7/lib-old',
 '/home/hernandezpalo/.virtualenvs/ERP/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/hernandezpalo/.virtualenvs/ERP/local/lib/python2.7/site-packages',
 '/home/hernandezpalo/.virtualenvs/ERP/lib/python2.7/site-packages']
Server time:    Jue, 31 May 2018 10:36:18 +0000

[edit by admin: formatting]

'default.db' is a relative path, not an absolute path. It looks like you've set up the database using the migrate commands in /home/hernandezpalo/django-erp, so you should specify the full absolute path in the DATABASES setting like this:

    'NAME': '/home/hernandezpalo/django-erp/default.db',

Thank you very much, this solved the problem

Excellent -- thanks for confirming!