Jump to content

Recommended Posts

Posted

I've installed Django 1.6.5 on my site on Stevie at http://ukanuk.heliohost.org/django2/. I'm creating the Basic Poll App Admin Site outlined at https://docs.djangop...m/en/1.6/intro/, I've mostly gotten through Part 3, and it works without flaw locally on my computer.

 

My two problems upon uploading to Heliohost, hopefully related, are:

1. The admin page isn't working properly. When I try to log in, it gives me this error page, where I think is the pertinent info is after the second question.

2. The root directory is not giving me a page saying something like http://ukanuk.helioh...org/djangotest/ (which uses Stevie's Django v1.3.0), as it does locally on my computer. My sample app here, however, utilizing all sorts of URL mumbo-jumbo, works perfectly.

 

Pertinent Error Page Info (Complete page here):

OperationalError at /admin/
unable to open database fileRequest Method: POST
Request URL: http://ukanuk.helioh.../django2/admin/
Django Version: 1.6.5
Exception Type: OperationalError
Exception Value: unable to open database file
Exception Location: /home/nuk/Django-1.6.5/django/db/backends/sqlite3/base.py in execute, line 451
Python Executable: /usr/bin/python
Python Version: 2.7.1

 

Context:

The default Django admin site utilizes SQLite for its database, and according to http://www.heliohost...atabases/sqlite the Python version should be 3.3.6, whereas my site is using the Stevie default 2.7.1. However, this Python version conflict seems improbable to me since SQLite embeds itself as a library instead of getting run by the server in its own script, and am running it locally with v2.7. In addition, "Exception Location of /home/nuk/Django-1.6.5/django/db/backends/sqlite3/base.py" above makes it seem like its using SQLite files bundled with Django. I think it more likely that there is some problem in my .htaccess, urls.py, or dispatch.wsgi files, but I'm not really sure where to start.

 

I have no idea why Problem #2 is happening beyond a problem in my .htaccess, urls.py, or dispatch.wsgi. Maybe it's easier to solve than #1, and maybe fixing it will fix #1 too, or vice versa.

 

/django2/.htaccess file

RewriteEngine On
RewriteBase /
RewriteRule ^(static/.*)$ - [L]
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(dispatch\.wsgi/.*)$ - [L]
RewriteRule ^(.*)$ django2/dispatch.wsgi/$1 [QSA,PT,L]

 

/django2/mysite/urls.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
)

 

/django2/dispatch.wsgi

import os, sys
sys.path.insert(1,'/home/nuk/Django-1.6.5');
sys.path.append("/home/nuk/public_html/django2");
sys.path.append("/home/nuk/public_html/django2/mysite");

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
os.environ.setdefault("PYTHON_EGG_CACHE", "/home/nuk/.python_egg_cache")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

 

I have also noticed that the admin site isn't properly getting its stylesheets, but I think this is probably just because I haven't properly set up my static files yet so I'm not as concerned about this.

 

Any ideas?

Posted

You have semicolons at the end of lines 2-4 in your dispatch.wsgi. Those shouldn't be there. That could be the source of files not routing properly.

Posted

I've removed the semicolons, but I don't think that's changed anything. I was able to properly load http://ukanuk.heliohost.org/django2/polls/5/, so it seems like even if it isn't correct, it's still getting through.

 

I was successful at fixing the admin page, at least as concerns accessing the database (I haven't messed with getting the static directory with its CSS files yet, so I'm assuming fixing that'll fix the styling issues). The fix was to change the permissions for the django2 directory (NOT recursively) from 555 to 777.

 

Concerning the second error, I think the built-in (local, non-web) django server must just be configured slightly differently, because if I remove all the url patterns from /mysite/urls.py, then I get the proper "It worked! Congratulations on your first Django-powered page" message. As soon as I configure any URLs, then it stops working. I'll assume that this error is inconsequential, if slightly inconvenient.

 

Hopefully once I have a nice sample site I can write a little tutorial in this forum explaining how to set it up, and with Python 3.4 :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...