Django Server Deployment - OperationalError on shared hosting ASO

74 views
Skip to first unread message

David F

unread,
Apr 18, 2015, 1:30:31 PM4/18/15
to django...@googlegroups.com
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

James Schneider

unread,
Apr 18, 2015, 7:28:51 PM4/18/15
to django...@googlegroups.com

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

--
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...@googlegroups.com.
To post to this group, send email to django...@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.

David F

unread,
Apr 19, 2015, 11:38:31 AM4/19/15
to django...@googlegroups.com

Hey James

Sorry I forgot to mention that I did run first ./manage.py syncdb to create a superuser for the database and the admin, and have run makemigrations and migrate several times throughout editing my models, still to no avail. I did it again after seeing your post just to be sure :p same error :/

Do you think it would help to just delete the database and recreate it would work or noooo...?

David F

unread,
Apr 19, 2015, 12:19:36 PM4/19/15
to django...@googlegroups.com
Or I'm using sqlite should I switch to mysql?

James Schneider

unread,
Apr 19, 2015, 7:15:43 PM4/19/15
to django...@googlegroups.com

No need to switch databases.

Do you have any shell access to the server? Can you manually inspect the database to see if the table actually exists (outside of any Django commands)? I'm not sure what ASO offers.

-James

On Apr 19, 2015 9:19 AM, "David F" <davidwy...@gmail.com> wrote:
Or I'm using sqlite should I switch to mysql?

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

David F

unread,
Apr 19, 2015, 8:36:42 PM4/19/15
to django...@googlegroups.com
sqlite> .read db.sqlite3
Error: incomplete SQL: SQLite format 3pp_label", "model")) �ite_autoindex_django_content_type_1django_content_type P ++ Ytablesqlite_sequencesqlite_sequence CREATE TABLE sqlite_sequence(name,seq)�Y // �atabledjango_migrationsdjango_migrations CREATE TABLE "django_migrations" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "app" varchar(255) NOT NULL, "name" varchar(255) NOT NULLontenttypes000 add Blog Entry4add_entry #Can add session add_session/)Can add permission add_tryadminlogentry

authuser authgroup ! authpermission adminlogentry
add_tag ) delete_session ) change_session # add_session 1 del # delete_user 1 change_contenttype + add_contenttype
                 # change_user
                                  add_user
% delete_group    % change_grou add_group / delete_permission / change_permission ) add_permission + delete_logentry + change_lodjango_migrations CREATE TABLE "django_migrations" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "app" varchar(255) NOT NULL, "name" varchar(255) NOT NULL, "applied" datetime NOT NULL)P ++ Ytablesqlite_sequencesqlite_sequence CREATE TABLE sqlite_sequence(name,seq)� 33 �3tabledjango_content_typedjango_content_typeCREATE TABLE "django_content_type" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(100) NOT NULL, "app_label" varchar(100) NOT NULL, "model" varchar(100) NOT NULL, UNIQUE ("app_label", "model"))E Y3 th_permission_1auth_permission� !! �ktableauth_groupauth_group
CREATE TABLE "auth_group" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(80) NOT NULL UNIQUE)3    G! 99 �
                                                  tableauth_group_permissionsauth_group_permissions
                   CREATE TABLE "auth_group_permissions" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "group_id" integer NOT NULL REFERENCES "auth_group" ("id"), "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id"), UNIQUE ("group_id", "permission_id"))K
                                   _9 RY KEY AUTOINCREMENT, "password" varchar(128) NOT NULL, "last_login" datetime NOT NULL, "is_superuser" bool NOT NULL, "username" varchar(30) NOT NULL UNIQUE, "first_name" varchar(30) NOT NULL, "last_name" varchar(30) NOT NULL, "email" varchar(75) NOT NULL, "is_staff" bool NOT NUL E r_user_permissions_1auth_user_user_permissions � =+ �)indexauth_permission_417f1b1cauth_permission CREATE INDEX auth_permission_417f1b1c ON "auth_permission" ("content_type_id")� K9 �7indexauth_group_permissions_0e939a4fauth_group_permissions CREATE INDEX auth_group_permissions_0e939a4f ON "auth_group_permissions" ("group_id")� K9 �Aindexauth_group_permissions_8373b171auth_group_permissions CREATE INDEX auth_group_permissions_8373b171 ON "auth_group_permissions" ("permission_id")~ ?- � indexauth_user_groups_e8701ad4auth_user_groups CREATE INDEX auth_user_groups_e8701ad4 ON "auth_user_groups" ("user_id")

   
       
   
uth_user_groups CREATE INDEX auth_user_groups_0e939a4f ON "auth_user_groups" ("group_id")�& SA �Eindexauth_user_user_permissions_e8701ad4auth_user_user_permissions CREATE INDEX auth_user_user_permissions_e8701ad4 ON "auth_user_user_permissions" ("user_id")�, SA �Qindexauth_user_user_permissions_8373b171auth_user_user_permissions CREATE INDEX auth_user_user_permissions_8373b171 ON "auth_user_user_permissions" ("permission_id")�' -- � tabledjango_admin_logdjango_admin_log CREATE TABLE "django_admin_log" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "action_time" datetime NOT NULL, "object_id" text NULL, "object_repr" varchar(200) NOT NULL, "action_flag" smallint unsigned NOT NULL, "change_message" text NOT NULL, "content_type_id" integer NULL REFERENCES "django_content_type" ("id"), "user_id" integer NOT NULL REFERENCES "auth_user" ("id"))
f1b1cdjango_admin_log CREATE INDEX django_admin_log_417f1b1c ON "django_admin_log" ("content_type_id")~ ?- � indexdjango_admin_log_e8701ad4django_admin_log!CREATE INDEX django_admin_log_e8701ad4 ON "django_admin_log" ("user_id")� !! � tableblog_entryblog_entry"CREATE TABLE "blog_entry" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" varchar(200) NOT NULL, "body" text NOT NULL, "slug" varchar(200) NOT NULL UNIQUE, "publish" bool NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL)3 G! , "ip_address" char(15) NOT NULL, "user_data" varchar(255) NOT NULL)�
                             �itableblog_tagblog_tag%CREATE TABLE "blog_tag" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "slug" varchar(200) NOT NULL UNIQUE)/ C ON "blog_entry_tags" ("entry_id")y$ =+ � indexblog_entry_tags_76f094bcblog_entry_tags+CREATE INDEX blog_entry_tags_76f094bc ON "blog_entry_tags" ("tag_id")�6% )) �'tabledjango_sessiondjango_session,CREATE TABLE "django_session" ("session_key" varchar(40) NOT NULL PRIMARY KEY, "session_data" text NOT NULL, "expire_date" datetime NOT NULL);& O) an add iadd_ip e user change_user


I have no idea what any of this means, but when I did a sqlite pragma integrity_check, it said "OK". when I am in python interpreter, it no longer imports my django app "blog", which IS listed in settings.py INSTALLED_APPS. I'm supremely confused


David F

unread,
Apr 19, 2015, 8:49:41 PM4/19/15
to django...@googlegroups.com
oh and yes-- I SSH into my part of the server that's how I'm able to do all this :X the database file is in the project folder just... it's coming up with that message when I try to open it in shell

David F

unread,
Apr 22, 2015, 4:45:28 PM4/22/15
to django...@googlegroups.com
Got it to work-- changed permissions of my shared part of the server using the bash:

chmod 755 .

thanks james for thinking through this with me
Reply all
Reply to author
Forward
0 new messages