我正在尝试将我的Django版本从1.4.6升级到1.7,但是我得到以下错误,我不知道如何解决:
我的tracestack如下:
C:\Users\user_name\Desktop\project_name\project_name>python ../manage.py runserver
Traceback (most recent call last):
File "../manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 354, in execute django.setup()
File "C:\Python27\lib\site-packages\django\__init__.py", line 21, in setup apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 115, in populate app_config.ready()
File "C:\Python27\lib\site-packages\debug_toolbar\apps.py", line 15, in ready dt_settings.patch_all()
File "C:\Python27\lib\site-packages\debug_toolbar\settings.py", line 215, in patch_all patch_root_urlconf()
File "C:\Python27\lib\site-packages\debug_toolbar\settings.py", line 203, in patch_root_urlconf reverse('djdt:render_panel')
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 517, in reverse app_list = resolver.app_dict[ns]
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 329, in app_dict self._populate()
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 269, in _populate for pattern in reversed(self.url_patterns):
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 367, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 361, in urlconf_module self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module __import__(name)
File "C:\Users\user_name\Desktop\project_name\project_name\urls.py", line 10, in <module> url(r'', include('project_name.users.urls')),
File "C:\Python27\lib\site-packages\django\conf\urls\__init__.py", line 28, in include urlconf_module = import_module(urlconf_module)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module __import__(name)
File "C:\Users\user_name\Desktop\project_name\project_name\users\urls.py", line 9, in <module> urlpatterns = patterns('django.contrib.auth.views', NameError: name 'patterns' is not defined
我正在使用python 2.7。
我已阅读更改文档,并且已替换所有我的网址标记,以便它们现在显示为:{%url“email_change”%}而不是{%url email_change%}
上述错误的最后一行是:
File "C:\Users\user_name\Desktop\project_name\project_name\users\urls.py", line 9, in <module> urlpatterns = patterns('django.contrib.auth.views', NameError: name 'patterns' is not defined
users / urls.py文件中此页面的代码是:
from django.conf.urls import patterns, include, url
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'', include('project_name.core.urls')),
url(r'', include('project_name.users.urls')),
url(r'', include('project_name.registration.urls')),
(r'^i18n/', include('django.conf.urls.i18n')),
# (r'^pages/', include('django.contrib.flatpages.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^rosetta/', include('rosetta.urls')),
url(r'^contact_us/', 'contact.views.contact_us', name='contact_us'),
(r'^ckeditor/', include('ckeditor.urls')),
)
# enable serving uploaded files in the DEBUG mode
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我假设错误消息,在新版本的Django下,url标记现在不正确。 任何人都可以提供一些帮助来解决这个问题,b / c我真的被困了吗?
** 编辑 - 添加核心urls.py文件 **
以下代码来自my core / urls.py文件
from django.conf.urls import patterns, url
urlpatterns = patterns('project_name.core.views',
# ACHIEVEMENT DETAILS.
url(r'^resume_details/achievement_details/$',
'achievement_details',
name='achievement_details'),
url(r'^resume_details/achievement_details/add/$',
'achievement_details_add',
name='achievement_details_add'),
url(
r'^resume_details/achievement_details/delete/(?P<achievement_details_id>\d+)/$',
'achievement_details_delete',
name='achievement_details_delete'),
url(
r'^resume_details/achievement_details/duplicate/(?P<achievement_details_id>\d+)/$',
'achievement_details_duplicate',
name='achievement_details_duplicate'),
url(
r'^resume_details/achievement_details/edit/(?P<achievement_details_id>\d+)/$',
'achievement_details_edit',
name='achievement_details_edit'),
....
答案 0 :(得分:1)
我从来没有解决过这个问题。
我没有直接从Django 1.4升级到1.7,而是逐步处理升级。
例如,将1.4升级到1.5,然后升级到1.6到1.6,再升级到1.6到1.7。确保在每次升级时测试项目。
以这种方式处理升级更易于管理。
我希望这有助于somone。
答案 1 :(得分:1)
不确定这是否有帮助,但我最近写了一篇关于如何从1.4升级到1.7的文章。肯定是很难学到很多东西。 labs.seedinvest.com/backend/upgrading-from-django-1-4-to-django-1-7/