ViewDoesNotExist 'index' attribute in contrib.admin.views.main

75 views
Skip to first unread message

Florencio Cano

unread,
Jul 21, 2008, 5:38:50 AM7/21/08
to django...@googlegroups.com
Hi!
I have updated Django from svn, installed a new app and some new
models and now when I try to browse /admin/ I get this error:

ViewDoesNotExist: Tried index in module
django.contrib.admin.views.main. Error was: 'module' object has no
attribute 'index'

I have checked that my user is the owner of all the files in
django.contrib.admin.views and I have checked that there not exist any
method in django.contrib.admin.views.main called index.

What is this attribute used for and how I can fix this error?

Florencio Cano

unread,
Jul 21, 2008, 6:32:49 AM7/21/08
to django...@googlegroups.com
The problem is that in the last versions in the repository of Django
the Admin interface has changed. More info in:
http://www.djangoproject.com/documentation/admin/
I have read the documentation but now I have another error. Now the
error is with the template index of the admin interface:

TemplateSyntaxError at /admin/
Caught an exception while rendering: u'user' Original Traceback (most
recent call last): File
"/usr/lib/python2.4/site-packages/django/template/debug.py", line 71,
in render_node result = node.render(context) File
"/usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/log.py",
line 18, in render self.user = context[self.user].id File
"/usr/lib/python2.4/site-packages/django/template/context.py", line
43, in __getitem__ raise KeyError(key) KeyError: u'user'

After reading the document the most importante change I see is
extracting the Admin class from the models and creating another class
called MyModelAdmin that extends admin.ModelAdmin and modifying the
urls.py to include:

urlpatterns = patterns('',
('^admin/(.*)', admin.site.root),
[...]

Any ideas to solve this problem in the new Admin interface version?

2008/7/21 Florencio Cano <florenc...@gmail.com>:

cschand

unread,
Jul 21, 2008, 7:05:03 AM7/21/08
to Django users
Did you add
admin.autodiscover()
in urls.py? I think the problem due to this
read
http://www.djangoproject.com/documentation/admin/#hooking-adminsite-instances-into-your-urlconf

Satheesh

V

unread,
Jul 21, 2008, 9:10:52 AM7/21/08
to Django users
I think the easyest way to see the difference is if you do a new
django-admin startproject, and check the comments in urls.py

then you can go on and have a look at the admin.site.root as well,
that is put in urls.py by default, but if you just want a basic admin
site, then probably you won't need it

at least, this is what I did, and now I understand pretty well what
has happened :)

V

On Jul 21, 12:32 pm, "Florencio Cano" <florencio.c...@gmail.com>
wrote:
> The problem is that in the last versions in the repository of Django
> the Admin interface has changed. More info in:http://www.djangoproject.com/documentation/admin/
> I have read the documentation but now I have another error. Now the
> error is with the template index of the admin interface:
>
> TemplateSyntaxError at /admin/
> Caught an exception while rendering: u'user' Original Traceback (most
> recent call last): File
> "/usr/lib/python2.4/site-packages/django/template/debug.py", line 71,
> in render_node result = node.render(context) File
> "/usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/log.py",
> line 18, in render self.user = context[self.user].id File
> "/usr/lib/python2.4/site-packages/django/template/context.py", line
> 43, in __getitem__ raise KeyError(key) KeyError: u'user'
>
> After reading the document the most importante change I see is
> extracting the Admin class from the models and creating another class
> called MyModelAdmin that extends admin.ModelAdmin and modifying the
> urls.py to include:
>
> urlpatterns = patterns('',
>     ('^admin/(.*)', admin.site.root),
>     [...]
>
> Any ideas to solve this problem in the new Admin interface version?
>
> 2008/7/21 Florencio Cano <florencio.c...@gmail.com>:

Florencio Cano

unread,
Jul 21, 2008, 9:15:16 AM7/21/08
to django...@googlegroups.com
Yes. I already have done that:

from django.conf.urls.defaults import *
from django.contrib import admin

import os

admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^seinhe/', include('seinhe.foo.urls')),

# Uncomment this for admin:
('^admin/(.*)', admin.site.root),


2008/7/21 cschand <csc...@gmail.com>:

Henhiskan

unread,
Jul 30, 2008, 10:03:36 PM7/30/08
to Django users
I had the same problem. The solution is update the new url.py (you
already did )
and drop the database and then re-sync you project (remember do a
backup of your data).
The new admin class have new tables on database, that works from me.

Read this:
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Mergednewforms-adminintotrunk


Suerte.-

Henhiskan

unread,
Jul 30, 2008, 10:13:07 PM7/30/08
to Django users
On Jul 30, 10:03 pm, Henhiskan <henhis...@gmail.com> wrote:
> I had the same problem. The solution is update the new url.py (you
> already did )
> and drop the database and then re-sync you project (remember do a
> backup of your data).
> The new admin class have new tables on database, that works from me.
>
> Read this:http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Merge...
>
> Suerte.-

... and also there was a change in the way to put your models into
admin
check this url:
http://www.djangoproject.com/documentation/admin/
Reply all
Reply to author
Forward
0 new messages