Jump to content

Configuring Django


Recommended Posts

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?

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...