Problems with turning on the Admin

69 views
Skip to first unread message

Keith Edmiston

unread,
Nov 8, 2013, 10:55:04 AM11/8/13
to django...@googlegroups.com
Hi,

I am building a new site in Django 1.4 and I'm using the South migration tool to keep my dev MySQL database in sync with changes made to my models. It should be said that I use one MySQL database account to serve various Django projects/apps (confusing, yes). It all seems to be working fine until I attempt to open up the Admin site from the project currently in development (bus/certs/admin/).

It *appears* that the autodiscover is trying to find a model "Listing" that is no longer in existence, but did exist in earlier development stages. I deleted that model and have since run a South migration to extend that deletion to the database.  That seems to have worked fine. What did not seem to happen is the removal of references to the "listing" table in the django_content_type and auth_permission tables, so I removed those manually thinking the autodiscover might be "seeing" those entries and subsequently attempting to find the model in "bus_models.models". That seems to have made no difference, the error still exists.

Not sure if this matters or not, but I had initially used the admin up in a separate project ("deans" vs. "certs") and it still works.  It even still lists the "Bus_models.Listing" model and only fails once I click on that link...gives me a "Table does not exist" error, as I would expect. This does make me think, however, that there is a lingering pointer somewhere that I'm unable to locate.

I can reliably cause this error to occur and go away again by uncommenting/commenting the following lines in my bus(app)/certs(proj)/urls.py file:

from django.contrib import admin
admin.autodiscover()
(r'^apps/bus/certs/admin/', include(admin.site.urls)),

Here is the traceback of the error page that shows up when the above are uncommented (no matter what url I use):
Environment:


Request Method: GET
Request URL: https://local.utexas.edu:8000/apps/bus/certs/application/1256/

Django Version: 1.4.3
Python Version: 2.6.7
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'utdirect',
 'bus.certs.application',
 'bus.certs.listing',
 'bus.certs.common',
 'bus.certs.bus_shared_common',
 'bus.certs.bus_models',
 'debug_toolbar',
 'ut_debug_toolbar',
 'south')
Installed Middleware:
('django.middleware.gzip.GZipMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'utdirect.middleware.HttpHeaderMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
  89.                     response = middleware_method(request)
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py" in process_request
  160.         request.urlconf = _build_urlconf(request)
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py" in _build_urlconf
  123.     class URLPatterns(object):
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py" in URLPatterns
  130.             url('', include(original_urlconf)),
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/conf/urls/__init__.py" in include
  24.         urlconf_module = import_module(urlconf_module)
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/pype/bus/certs/urls.py" in <module>
  7. admin.autodiscover()
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/contrib/admin/__init__.py" in autodiscover
  29.             import_module('%s.admin' % app)
File "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)

Exception Type: NameError at /apps/bus/certs/application/1256/
Exception Value: name 'Listing' is not defined

Lastly, I have searched in as many ways I can think to search for any reference to "Listing" in the database and code base, but cannot find anything.

Any help would be greatly appreciated.

Regards,

--
Keith 

Vincenzo Prignano

unread,
Nov 8, 2013, 11:39:45 AM11/8/13
to django...@googlegroups.com
'bus.certs.listing' is this entry in your installed apps referring to the "Listing" models perhaps? We can't really help you with much more info btw.

Keith Edmiston

unread,
Nov 8, 2013, 12:48:28 PM11/8/13
to django...@googlegroups.com
Sorry...I was trying to be careful of not putting so much info in the email that it became too much.

My project structure is (in part):
--bus/certs
    |_ application
      |_ __init__
      |_ models.py --> empty, using common/models.py & bus_models/models.py
      |_ urls.py
      |_ views.py

    |_ bus_models (svn: externals)
      |_ __init__
      |_ models.py --> Person

    |_ bus_shared_common (svn: externals)
      |_ __init__
      |_ static (css, js, etc.)
      |_ templates

    |_ common
      |_ __init__
      |_ models.py --> Program, Status, Application, Notes, Action, Correspondence

    |_ listing
      |_ __init__
      |_ models.py --> empty, using common/models.py & bus_models/models.py
      |_ urls.py --> only one regex so far..."listing", which calls "listing" in views.py
      |_ views.py --> "listing" function

So, in answer to your question Vincenzo, bus.certs.listing does not make a call to any model just yet.  Thanks for suggesting I look though.

Keith


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4b59f61d-4537-42c8-af0a-79daa04aa19a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Keith Edmiston
(512)970-7222

Vincenzo Prignano

unread,
Nov 8, 2013, 1:20:17 PM11/8/13
to django...@googlegroups.com
Can you post the line in urls.py that is calling the view function?

Keith Edmiston

unread,
Nov 8, 2013, 3:04:54 PM11/8/13
to django...@googlegroups.com
bus/certs/urls.py:

from django.conf.urls import patterns, url, include
from django.conf import settings
from bus.certs.views import index


from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
                       (r'^apps/bus/certs/$', index),
                       (r'^apps/bus/certs/index$', index),
                       (r'^apps/bus/certs/listing/', include('bus.certs.listing.urls')),
                       (r'^apps/bus/certs/application/', include('bus.certs.application.urls')),
                       (r'^apps/bus/certs/admin/', include(admin.site.urls)),
                       )

bus/certs/listing/urls.py:

from django.conf.urls import patterns, url, include
from django.conf import settings
from listing.views import listing

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('bus.certs.listing.views',
                       (r'^$', listing, {}, 'listing'),
                       )

bus/certs/application/urls.py:

from django.conf.urls import patterns, url, include
from django.conf import settings
from application.views import application_view, application_submit, application_update

# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()

urlpatterns = patterns('bus.certs.application.views',
                       (r'^(?P<app_id>\d+)/$', application_view, {}, 'application_view'),
                       (r'^update/(?P<app_id>\d+)/$', application_update, {}, 'application_update'),
                       (r'^submit/$', application_submit, {}, 'application_submit'),
                       #(r'^admin/', include(admin.site.urls)),
                       )



For more options, visit https://groups.google.com/groups/opt_out.



--
Keith Edmiston
(512)970-7222

Keith Edmiston

unread,
Nov 9, 2013, 12:53:18 PM11/9/13
to django...@googlegroups.com
Bumping this up once more just in case someone may have any thoughts...still a problem that has me stumped. Thanks, in advance, for ideas. 

Keith
--
Keith Edmiston
(512)970-7222


--
Keith Edmiston
(512)970-7222

Vincenzo Prignano

unread,
Nov 9, 2013, 1:00:06 PM11/9/13
to django...@googlegroups.com
Sorry but I still can’t see the problem here. You are by the way using an old Django version and an old Python version. That’s the only thing I can think about right now.

-- 
Vincenzo Prignano
Sent with Sparrow

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/kP88FP75liE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Keith Edmiston

unread,
Nov 11, 2013, 6:11:42 PM11/11/13
to django...@googlegroups.com
UPDATE: this problem was caused by latent .pyc files on my localhost machine. Deletion of those removed this issue. 

Thanks for the help. 

Keith
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/groups/opt_out.


--
Keith Edmiston
(512)970-7222
Reply all
Reply to author
Forward
0 new messages