Saturday, April 18, 2015

Re: Django Server Deployment - OperationalError on shared hosting ASO

You don't mention running 'manage.py makemigrations' or 'manage.py migrate' in any of your output. The error you are getting indicates that Django has access to a database, but the table schema is incorrect. If you haven't previously run migrate, then you have no tables, which explains the error you are getting.

-James

On Apr 18, 2015 10:30 AM, "David F" <davidwyfrazier@gmail.com> wrote:
Hi guys!! Great to be a part of the community.

So as the title says, I am deploying a site I made locally to a shared hosting server through "A Small Orange" or ASO. My site structure is as follows:

don't judge my naming structure :p (unless it actually is messing something up)

/home/my_username:
-.env
- public_html:
- .htaccess
- dispatch.fcgi
- <symlink to blog app> blog:
- <symlink to static> mysite:
- <symlink to templates> templates:
- media
- static
- templates
- my_site:
- db.sqlite3
- manage.py
- blog:
- __init__.py
- feed.py
- models.py
- admin.py
- views.py
- urls.py
- my_site:
- __init__.py
- email_info.py
- settings.py
- urls.py
- wsgi.py



I've installed django and all relevant stuff like installed apps in a vrtualenv. Here's the .htaccess file:

ErrorDocument 500 "<h1>Server error. Sorry.</h1>"

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]


And the dispatch.fcgi:

#!/home/jeheyvyc/.env/env/bin/python

import sys
import os

sys.path.insert(0, '/home/my_username/.env/env/lib/python2.7/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = 'my_site.settings'

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")


And my settings.py

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

from .email_info import *

EMAIL_USE_TLS = EMAIL_USE_TLS
EMAIL_HOST = EMAIL_HOST
EMAIL_HOST_USER = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = EMAIL_HOST_PASSWORD
EMAIL_PORT = EMAIL_PORT

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = SECRET_KEY

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = [

    'mysite.com',

]

ADMIN = (

    ('My_admin', '<my_email_address>'),

)


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
    'dj_static',
    'django_markdown',
)

MIDDLEWARE_CLASSES = (


    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'my_site.urls'

WSGI_APPLICATION = 'my_site.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

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

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_ROOT = 'staticfiles'

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    '/home/my_username/mysite.com/static/',
    '/home/my_username/.env/env/lib/python2.7/site-packages/django/contrib/admin/static/',

)

TEMPLATE_DIRS = (

    '/home/my_username/mysite.com/templates/',
 )



And so when I access the site I am greeted with this:


OperationalError at /

no such table: blog_entry
Request Method: GET
Request URL: http://mysite.com/
Django Version: 1.7
Exception Type: OperationalError
Exception Value:
no such table: blog_entry
Exception Location: /home/my_username/.env/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 485
Python Executable: /home/my_username/.env/env/bin/python
Python Version: 2.7.8
Python Path:
['/home/my_username/mysite.com/my_site',   '/home/my_username/.env/env/lib/python2.7/site-packages',   '/home/my_username/public_html',   '/home/my_username/.env/env/lib/python27.zip',   '/home/my_username/.env/env/lib/python2.7',   '/home/my_username/.env/env/lib/python2.7/plat-linux2',   '/home/my_username/.env/env/lib/python2.7/lib-tk',   '/home/my_username/.env/env/lib/python2.7/lib-old',   '/home/my_username/.env/env/lib/python2.7/lib-dynload',   '/usr/lib/python2.7',   '/usr/lib/python2.7/plat-linux2',   '/usr/lib/python2.7/lib-tk']
Server time: Sat, 18 Apr 2015 16:57:50 +0000




And on the backend are the following errors:


Well my account isn't showing me the errors after accessing the site (it does that sometimes) I'll post it later when it's working.


So yea based off of that, whaddaya guys think? Cuz I'm not the greatest at this stuff right now I'm in the "I totally suck but can admit it" stage of learning django and web dev :p

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d85339f1-0d45-4595-8d4e-2eb2ea04826b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUC%3D5%2BTDjBW-cJHPkcL2MqrKX-C_Op6eeehHzjKV_g%3Drg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment