Deploying Django - can't get past the welcome screen

70 views
Skip to first unread message

Darthmahon

unread,
Feb 16, 2008, 10:00:45 AM2/16/08
to Django users
Hi Guys,

In the final steps of my app and looking to deploy (yay!). I'm using a
dedicated server which has Apache 2 and is using FastCGI with
Lighttpd.

Django installed, the models are in, the mysql database is working but
I can't get past this welcome screen:

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It worked!
Congratulations on your first Django-powered page.

Of course, you haven't actually done any work yet. Here's what to do
next:
If you plan to use a database, edit the DATABASE_* settings in
thumbslap/settings.py.
Start your first app by running python thumbslap/manage.py startapp
[appname].
You're seeing this message because you have DEBUG = True in your
Django settings file and you haven't configured any URLs. Get to work!
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Now - I have set up everything it mentions above and I have even
turned DEBUG to False. I've created my project.fcgi file alongside
my .htaccess file, both of which I have ran the "touch" command on to
restart.

Basically, no matter what I put after my URL it always points to the
welcome page E.G. www.mysite.com/admin/ or www.mysite.com/static/

Any ideas?

Cheers,
Chris

Bret W

unread,
Feb 16, 2008, 2:57:37 PM2/16/08
to Django users
Have you edited your urls.py file?

You'll need to make sure the admin site is enabled by uncommenting
this line:
(r'^admin/', include('django.contrib.admin.urls')),

And you'll also need to make sure you have:
'django.contrib.admin',
in the INSTALLED_APPS section of your settings.py file. Make sure to
run ./manage.py syncdb after adding it.

Darthmahon

unread,
Feb 16, 2008, 3:58:54 PM2/16/08
to Django users
Hi Bret,

Yea I've done both of those things, ran syncdb as well.

It's very odd. For example I have a /static/ folder that just has all
of my css files, but even when I try to access that folder it shows
the Django Welcome screen. I wouldn't expect that to happen...

Bret W

unread,
Feb 16, 2008, 4:05:16 PM2/16/08
to Django users
Have you restarted the Web server? Perhaps caching is playing a role
here.
The admin section should be working no problem, as long as the
settings and urls files are as described.

Darthmahon

unread,
Feb 16, 2008, 4:43:26 PM2/16/08
to Django users
Yea I've restarted it and "touched" the fcgi file so it's rather odd -
do you know of any good tutorials that are not written by the Django
team (read them, not too helpful and assume too much)?

Bret W

unread,
Feb 16, 2008, 4:53:40 PM2/16/08
to Django users
Could you post your urls.py and settings files?
Message has been deleted

Darthmahon

unread,
Feb 17, 2008, 5:52:31 AM2/17/08
to Django users
======================================
File: urls.py
======================================
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
(r'^$', 'mysite.views.index'),
(r'^settings/', 'mysite.people.views.settings'),
(r'^register/', 'mysite.people.views.register'),
(r'^login/', 'mysite.views.login'),
(r'^logout/', 'mysite.people.views.logout'),
(r'^people/', include('mysite.people.urls')),
(r'^friends/', 'mysite.people.views.friends'),
)
======================================
File: settings.py
======================================
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ADMINS = (
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'mysql'
DATABASE_NAME = 'xxxx'
DATABASE_USER = 'xxxx'
DATABASE_PASSWORD = 'xxxx'
DATABASE_HOST = 'xxxx'
DATABASE_PORT = ''
DATABASE_OPTIONS = {'read_default_file': '/etc/my.cnf',}
TIME_ZONE = 'Europe/London'
LANGUAGE_CODE = 'en-gb'
SITE_ID = 1
USE_I18N = True
MEDIA_ROOT = '/home/mysite/static'
MAX_PHOTO_UPLOAD_SIZE = 500000
MAX_PHOTO_WIDTH = 500000
MAX_PHOTO_WIDTH = 500000
MEDIA_URL = 'http://static.mysite.com/'
ADMIN_MEDIA_PREFIX = '/media/'
SECRET_KEY = 'xxxx'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
AUTH_PROFILE_MODULE = "people.userprofile"
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'mysite.context_processors.static_url',
'mysite.context_processors.user_profile',
'django.core.context_processors.request',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)
ROOT_URLCONF = 'mysite.urls'
TEMPLATE_DIRS = (
'/home/mysite/templates',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.humanize',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'mysite.people',
)

Brian Luft

unread,
Feb 17, 2008, 1:58:29 PM2/17/08
to Django users
Your code is apparently in a project called "thumbslap":

>If you plan to use a database, edit the DATABASE_* settings in
>thumbslap/settings.py.
>Start your first app by running python thumbslap/manage.py startapp
>[appname].

But your settings file is ROOT_URL_CONF set to "mysite.urls". Is that
in fact the correct URLs file?

I would suggest jumping into the python interpreter and importing your
desired settings file, check the __file__/__path__ module attributes
and also do the same with your urls.py file just to make sure you
aren't loading something unexpected.

-Brian
Message has been deleted

Darthmahon

unread,
Feb 19, 2008, 10:40:58 AM2/19/08
to Django users
Hi guys - anyone got any thuoghts on this? Not sure where else I can
go to get help.

On Feb 18, 8:58 pm, Darthmahon <cpma...@gmail.com> wrote:
> Hi Brian,
>
> I know how to get into python but not sure the exact commands to
> import settings.py? I tried "import settings" and it didn't come back
> with an error.
>
> How do I check the __file__/__path__ module attributes?
>
> I am now running into a weird intermittent issue which is actually not
> showing the welcome page anymore, but it showing a Django error (which
> is good) but I actually have Debug set to False which means I
> shouldn't be seeing this page!
>
> I am now thinking my settings.py file is not being called properly.
> Here is part of the error message screen (some parts changed to X):
>
> DOCUMENT_ROOT
> '/home/mysite'
> GATEWAY_INTERFACE
> 'CGI/1.1'
> HTTP_ACCEPT
> 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/
> plain;q=0.8,image/png,*/*;q=0.5'
> HTTP_ACCEPT_ENCODING
> 'gzip, deflate'
> HTTP_ACCEPT_LANGUAGE
> 'en-us'
> HTTP_AREA51
> '1'
> HTTP_CACHE_CONTROL
> 'max-age=0'
> HTTP_CONNECTION
> 'keep-alive'
> HTTP_COOKIE
> 'PHPSESSID=XXXX
> HTTP_HOST
> 'mysite.com'
> HTTP_USER_AGENT
> 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/
> 523.10.6 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6'
> PATH_INFO
> '/'
> PATH_TRANSLATED
> '/home/mysite/'
> QUERY_STRING
> ''
> REDIRECT_STATUS
> '200'
> REDIRECT_URI
> '/mysite.fcgi/'
> REMOTE_ADDR
> 'XX.XXX.XX.XXX'
> REMOTE_PORT
> 'XXXXX'
> REQUEST_METHOD
> 'GET'
> REQUEST_URI
> '/'
> SCRIPT_FILENAME
> '/home/mysite/mysite.fcgi'
> SCRIPT_NAME
> '/mysite.fcgi'
> SERVER_ADDR
> '69.72.215.66'
> SERVER_NAME
> 'mysite.com'
> SERVER_PORT
> '8251'
> SERVER_PROTOCOL
> 'HTTP/1.1'
> SERVER_SOFTWARE
> 'lighttpd/1.4.18'
> wsgi.errors
> <flup.server.fcgi_base.TeeOutputStream object at 0x2aaaafc52bd0>
> wsgi.input
> <flup.server.fcgi_base.InputStream object at 0x2aaaafc4c450>
> wsgi.multiprocess
> True
> wsgi.multithread
> False
> wsgi.run_once
> False
> wsgi.url_scheme
> 'http'
> wsgi.version
> (1, 0)
>
> Anything in there stand out as an issue?
>
> Cheers,
> Chris
>
> On Feb 17, 6:58 pm, Brian Luft <luftyl...@gmail.com> wrote:
>
> > Your code is apparently in a project called "thumbslap":
>
> > >If you plan to use a database, edit the DATABASE_* settings in
> > >thumbslap/settings.py.
> > >Start your first app by running python thumbslap/manage.py startapp
> > >[appname].
>
> > But your settings file is ROOT_URL_CONF set to "mysite.urls". Is that
> > in fact the correct URLs file?
>
> > I would suggest jumping into the python interpreter and importing your
> > desired settings file, check the __file__/__path__ module attributes
> > and also do the same with your urls.py file just to make sure you
> > aren't loading something unexpected.
>
> > -Brian
>

Brian Luft

unread,
Feb 19, 2008, 3:18:44 PM2/19/08
to Django users
I'm not familiar with using FastCGI setups so I can't be of much help
there. Based on the contents of this thread, it is hard to tell what
you've done and what the state of your setup is. All I can suggest is
to ask the fundamental questions and make sure at each stage your
setup makes sense:

1) First of all, does your site work with the built-in development
webserver on the machine you are trying to deploy it on? (manage.py
runserver). If it works OK with the dev server and not with the
FastCGI server we can logically conclude something funky with your
FastCGI configuration.

2) Regardless of the actual webserver and/or extension/modules being
used, eventually it will all boil down to a Python process running
your application code. The Python process is going to have loaded
Django - dictated by whatever django request handler is pertinent for
your setup. At some, point it will want to bring in your settings so
that all the relevant resources for your project can be processed
(models, URLs, middleware, signals, DB connection, etc). To follow up
on my earlier post:

>> import yourproject.settings
OR
>> import settings
depending on how your path is set

>> settings.__file__
>> settings.__path__

If you could post your settings and fcgi files at dpaste that might be
helpful. I guess what I'm trying to get at is try to remove
complexity from the picture. If you think your settings file is not
being loaded or potentially the wrong one, then import it yourself
from a python interpreter and verify that you get what you expect.

Darthmahon

unread,
Feb 19, 2008, 4:08:46 PM2/19/08
to Django users
Hi Brian,

Imported settings - no errors. Couldn't get anything when I tried to
get settings.__path__ value.

Here are my files, both of which live in /home/mysite/

/mysite/ is my project directory and was created using django-admin.py
startproject mysite whilst in /home/

======================================
File: /home/mysite/mysite.fcgi
======================================

#!/usr/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/usr/local/bin/python")

# Switch to the directory of your project. (Optional.)
os.chdir("/home/mysite")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

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

======================================
File: /home/mysite/settings.py

Will McCutchen

unread,
Feb 19, 2008, 10:44:11 PM2/19/08
to Django users
Hi,

On Feb 19, 3:08 pm, Darthmahon <cpma...@gmail.com> wrote:
> # Add a custom Python path.
> sys.path.insert(0, "/usr/local/bin/python")

This bit might be part of your problem. I think this should be
something like

sys.path.insert(0, "/home")

because you're referring to "mysite.settings" as your
DJANGO_SETTINGS_MODULE.

Hope this helps,


Will.
Reply all
Reply to author
Forward
0 new messages