How to solve the problem with Django admin?

5cf8c2d15f5bb895392396.png
AttributeError at /admin/ 'module' object has no attribute 'rindex'
The problem only occurs when you try to go to the admin page 127.0.0.1:8000/admin/
I can't say exactly after which there was a problem, but noticed after I added a new module.

Trace:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/

Django Version: 1.8.3
Python Version: 3.4.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
'photo',
'news',
'announce',
'contact',
'chief',
'birthday',
'bc')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')


Traceback:
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\handlers\base.py" in get_response
 132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\contrib\admin\sites.py" in wrapper
 254. return self.admin_view(view, cacheable)(*args, **kwargs)
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\utils\decorators.py" in _wrapped_view
 110. response = view_func(request, *args, **kwargs)
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\views\decorators\cache.py" in _wrapped_view_func
 57. response = view_func(request, *args, **kwargs)
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\contrib\admin\sites.py" in inner
 223. if request.path == reverse('admin:logout', current_app=self.name):
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in reverse
 550. app_list = resolver.app_dict[ns]
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in app_dict
 352. self._populate()
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in _populate
 308. for name in pattern.reverse_dict:
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in reverse_dict
 338. self._populate()
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in _populate
 326. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in callback
 247. self._callback = get_callable(self._callback_str)
File "C:\Python34\lib\functools.py" in wrapper
 448. result = user_function(*args, **kwds)
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in get_callable
 96. mod_name, func_name = get_mod_func(lookup_view)
File "C:\Python34\lib\site-packages\django-1.8.3-py3.4.egg\django\core\urlresolvers.py" in get_mod_func
 159. dot = callback.rindex('.')

Exception Type: AttributeError at /admin/
Exception Value: 'module' object has no attribute 'rindex'


website url:
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns, static
from django.conf.urls.static import static
from khm.settings import *
from main.views import *


mapping includes = [
 url(r'^admin/', include(admin.site.urls)),
 url(r'^photo/', include("photo.urls")),
 url(r'^news/', include("news.urls")),
 url(r'^announce/', include("announce.urls")),
 url(r'^contact/', include("contact.urls")),
 url(r'^chief/', include("chief.urls")),
 url(r'^birthday/', include("birthday.urls")),
 url(r'^bc/', include("bc.urls")),
]

mapping includes += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
mapping includes += staticfiles_urlpatterns()
mapping includes += url(r'^', include("main.urls")),


the url of the app:
from django.conf.urls import include, url
from birthday.views import *

mapping includes = [
 url(r'^', bthd, name="bthd"),
]


model application:
from django.db import models

class song(models.Model):
 name = models.CharField(max_length=256, verbose_name="full name", null=True, blank=True)
 dob = models.DateField()
 pn = models.IntegerField(verbose_name="number", null=True, blank=True)
 photo = models.ImageField(upload_to='birthday/photo',verbose_name="Photo"
 blank=False, null=False, default='birthday/photo/photo.jpg')

 def __str__(self):
 return self.name

 class Meta():
 db_table = "birthdays"
 verbose_name = "birthdays"


Admin application:
from django.contrib import admin
from birthday.models import *
from birthday.views import *

class Birthday_admin(admin.ModelAdmin):
 fields = ('name', 'dob', 'pn', 'photo',)
 ordering = ('-dob',)
 list_display = ('name', 'dob')

admin.site.register(Birthday, Birthday_admin)


settings:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
'photo',
'news',
'announce',
'contact',
'chief',
'birthday',
'bc',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'khm.urls'

TEMPLATES = [
{
 'BACKEND': 'django.template.backends.django.DjangoTemplates',
 'DIRS': ['C:/Python34/khm/main/template',
'C:/Python34/khm/photo/template',
'C:/Python34/khm/announce/template',
'C:/Python34/khm/news/template',
'C:/Python34/khm/contact/template',
'C:/Python34/khm/chief/template',
'C:/Python34/khm/birthday/template',
'C:/Python34/khm/bc/template',
],
 'APP_DIRS': True,
 'OPTIONS': {
 'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.media',
'django.core.context_processors.media',
],
},
},
]

WSGI_APPLICATION = 'khm.wsgi.application'



DATABASES = {
 'default': {
 'ENGINE': 'django.db.backends.sqlite3',
 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}



LANGUAGE_CODE = 'EN-us'

TIME_ZONE = 'Europe/Moscow'

USE_I18N = True

USE_L10N = True

USE_TZ = True



STATIC_URL = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)

MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = '/uploads/'

LOGIN_URL = "login"
LOGOUT_URL = "logout"
LOGIN_REDIRECT_URL = "/"
LOGOUT_URL_REDIRECT_URL = "/"

AUTH_USER_MODEL = 'main.AuthUser'


birthday.views:
from django.shortcuts import render, render_to_response, redirect
from django.template import RequestContext
from birthday.models import *
from datetime import date

#today = date.today()

def bthd(request):
 args = {}
 return render_to_response("bd.html", args, context_instance=RequestContext(request))
"""
 args['birthdays'] = Birthday.objects.order_by('-dob')
 if Birthday.objects.get(dob=today):
 args['bd_today'] = Birthday.objects.get(dob=today)
 args['birthdays'] = Birthday.objects.order_by('-dob')
 return render_to_response("bd.html", args, context_instance=RequestContext(request))
else:
 args['birthdays'] = Birthday.objects.order_by('-dob')
 return render_to_response("bd.html", args, context_instance=RequestContext(request))
 """
March 23rd 20 at 19:19
1 answer
March 23rd 20 at 19:21
Solution
from django.conf.urls import include, url
from birthday.views import *

mapping includes = [
 url(r'^', bthd, name="bthd"),
]

bthd is the name of the view?
A similar problem is described on SOF

And it is related to an incorrect view name in urls.py. Recheck at home.
Added to the question code views. The names are the same. The methodology that I am guided from app to app identical. Ie all do the same and therefore can't understand what the problem is.
On the page itself(birthday) transition is made, the problem occurs when switching to admin area - delphine.Bashirian commented on March 23rd 20 at 19:24
@delphine.Bashirian, thecommentary all the url-patterns in addition to first - admin and try. If open, recommencerai one by one and verify. If not, you misspelled it.

Actually you have a pretty old version of Jangi. This is not good. Learn on the new. (Version and time) - Colleen commented on March 23rd 20 at 19:27

Find more questions by tags Django