views:

266

answers:

1

Here is my setup. I am using Django version 1.1.1 on Dreamhost, Python 2.4. The problem I am having is whenever I create a simple app and also have admin.autodiscover() enabled, Django will throw an exception. My setup:

from django.conf.urls.defaults import *
from testapp.views import HelloWorld

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^HelloWorld/$', HelloWorld),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
)

My settings.py looks like:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.admindocs',
'testapp',
)

My testapp.views looks like:

from django.http import HttpResponse

def HelloWorld(request):
    return HttpResponse("Hello world")

If I comment out admin.autodiscover() I can get to my view of HelloWorld. If I enable admin.autodiscover() Django throws an exception that I am not able to trap.

Does anyone know why this might be happening and what I can do to fix it?

+1  A: 

I'm going to guess that testapp/admin.py does not import the models.Model class you are creating admin for. Try the following:

./manage.py shell # you may immediately get a stack trace
>> import testapp.admin # I'll bet it blows up.
Peter Rowell
Yep - when I get try to import testapp.admin I get an ImportError exception
letsgofast