Я работаю с книгой Django 1.0 Website Development.В главе 8 я не могу заставить приложение администратора работать.Вот обратная связь, которую я получаю.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.3
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.comments',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_bookmarks.bookmarks',
'debug_toolbar',
'django.contrib.admin',
'django.contrib.admindocs']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware')
Traceback:
File "/usr/local/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
101. request.path_info)
File "/usr/local/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
158. return ResolverMatch(self.callback, args, kwargs, self.name)
File "/usr/local/lib/python2.6/site-packages/django/core/urlresolvers.py" in _get_callback
169. mod_name, func_name = get_mod_func(self._callback_str)
File "/usr/local/lib/python2.6/site-packages/django/core/urlresolvers.py" in get_mod_func
113. dot = callback.rindex('.')
Exception Type: AttributeError at /admin/
Exception Value: 'NoneType' object has no attribute 'rindex'
Вот мой раздел INSTALLED_APPS из файла settings.py:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.comments',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_bookmarks.bookmarks',
'debug_toolbar',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
)
Вот мой файл admin.py:
from django.contrib import admin
from bookmarks.models import *
class LinkAdmin(admin.ModelAdmin):
pass
class TagAdmin(admin.ModelAdmin):
pass
class BookmarkAdmin(admin.ModelAdmin):
list_display = ('title', 'link', 'user')
list_filter = ('user',)
ordering = ('title',)
search_fields = ('title',)
admin.site.register(Link, LinkAdmin)
admin.site.register(Tag, TagAdmin)
admin.site.register(Bookmark, BookmarkAdmin)
Вот мойФайл urls.py:
import os
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from bookmarks.views import *
from django.contrib import admin
admin.autodiscover()
site_media = os.path.join(os.path.dirname(__file__), 'site_media')
urlpatterns = patterns('',
# Admin interface
(r'^admin/(.*)', admin.site.root_path),
# Browsing
(r'^$', main_page),
(r'^popular/$', popular_page),
(r'^user/(\w+)/$', user_page),
(r'^tag/([^\s]+)/$', tag_page),
(r'^tag/$', tag_cloud_page),
(r'^search/$', search_page),
(r'^bookmark/(\d+)/$', bookmark_page),
# Session management
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', logout_page),
(r'^register/$', register_page),
(r'^register/success/$', direct_to_template,
{'template': 'registration/register_success.html'}),
# Account management
(r'^save/$', bookmark_save_page),
(r'^vote/$', bookmark_vote_page),
# Site media
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': site_media}),
# Ajax
(r'^ajax/tag/autocomplete/$', ajax_tag_autocomplete),
# Comments
(r'^comments/', include('django.contrib.comments.urls')),
)
Я попытался скопировать файл urls.py из исходного кода книги = NADA.Я читал различные другие сообщения на форуме об ошибках атрибутов, но не могу найти сценарий, который соответствует моему.Ваши идеи и предложения приветствуются.