从Django 1.8升级到1.10并且TemplateDoesNotExist错误

时间:2017-10-27 13:19:47

标签: python django

我将Django版本从1.8升级到1.10,我不得不删除site_packages文件夹中各种文件中的patterns()。

我遇到了这样的错误:

File "C:\Python27\lib\site-packages\import_export\admin.py", line 266, in get_urls
my_urls = patterns( 
NameError: global name 'patterns' is not defined

因此,根据折旧guidelines,我在admin.py文件中将代码更改为此。

my_urls = [
        url(r'^process_import/$',
            self.admin_site.admin_view(self.process_import),
            name='%s_%s_process_import' % info),
        url(r'^import/$',
            self.admin_site.admin_view(self.import_action),
            name='%s_%s_import' % info),
    ]
    return my_urls + urls

我在site_packages文件夹中重复了3次。

但是我现在收到TemplateDoesNotExist错误:

   Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/view_shifts/

Django Version: 1.10.8
Python Version: 2.7.13
Installed Applications:
['django.contrib.auth',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.messages',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'bootstrapform',
 'pinax_theme_bootstrap',
 'account',
 'metron',
 'pinax.eventlog',
 'table',
 'import_export',
 'django_tables2',
 'django_filters',
 'wordcloud',
 'mathfilters',
 'capes_mantle',
 'shift',
 'usereval',
 'finance']
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']

Template loader postmortem
Django tried loading these templates, in this order:

Using engine :
    This engine did not provide a list of tried templates.


Traceback:

File "C:\Python27\lib\site-packages\django\core\handlers\exception.py" in inner
  42.             response = get_response(request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "C:\Users\User\Documents\Repositories\up-capes-mantle\shift\views.py" in view_shifts
  1229.     return render(request, 'shifts/view_shifts.html', {'shifts': shift_list, 'is_internals':is_internals})

File "C:\Python27\lib\site-packages\django\shortcuts.py" in render
  30.     content = loader.render_to_string(template_name, context, request, using=using)

File "C:\Python27\lib\site-packages\django\template\loader.py" in render_to_string
  67.         template = get_template(template_name, using=using)

File "C:\Python27\lib\site-packages\django\template\loader.py" in get_template
  25.     raise TemplateDoesNotExist(template_name, chain=chain)

Exception Type: TemplateDoesNotExist at /view_shifts/
Exception Value: shifts/view_shifts.html

我不知道该怎么做,任何帮助都表示赞赏。如果我在详细说明我的代码时犯了一些错误,我很抱歉,因为这是我的第一个问题。

0 个答案:

没有答案