I'm hoping someone can help me out with this issue I'm having as it seems like a simple one but I've been banging my head on this for the past couple hours with no solace. OK, so I set up Django following the A2 Hosting guide here.
And I'm just not able to communicate with my views.py file.
Let me show you some files as I'm hoping its just some blatant error.
public_html/mysite/mysite/setup.py:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'nfl'
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '*******',
'USER': '*******',
'PASSWORD': '***',
'HOST': '',
'PORT': '5432',
}
}
STATIC_URL = '/static/'
TEMPLATE_DIRS = (
"nfl/templates",
)
public_html/mysite/mysite/urls.py:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^home/', 'nfl.views.home', name='home'),
]
public_html/mysite/nfl/views.py:
from django.shortcuts import render_to_response
import nfldb
import requests
# Create your views here.
def home(request):
db = nfldb.connect()
q = nfldb.Query(db)
year = request.GET['year']
if year is none:
year = 2014
q.game(season_year=year, season_type='Regular')
qb = []
for pp in q.sort('passing_yds').limit(10).as_aggregate():
qb.append(pp)
return render_to_response('index.html', {'qb' : qb})
public_html/mysite/nfl/templates/index.html:
just a helloworld html file to test
.htaccess:
AddHandler fcgid-script .fcgi
RewriteEngine on
# Set up static content redirect:
RewriteRule static/(.+)$ mysite/public/static/$1
# The following two lines are for FastCGI:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ application.fcgi/$1 [QSA,L]
And when I go to my domain, I just get the basic congrats on your first Django app page.
So what am I missing here? I copied most over from my local machine because it was working there on the local host with the Django runserver
but now I can't seem to link my views.
Let me know if there's any other info needed or if there's a better website to go to.
My setup:
- Python: 2.7
- Django: 1.85