你能帮助我吗,我已经下载了社交项目。然后,我使用命令行转到该文件夹,然后键入migrate然后运行runserver,我在命令行中收到这些警告:
C:\django\social\social\urls.py:25: RemovedInDjango110Warning:
django.conf.urls.patterns() is deprecated and will be removed in Django
1.10. Update your urlpatterns to be a list of django.conf.urls.url()
instances instead.
url(r'^checkuser/$', views.checkuser, name='checkuser'),
C:\Program Files\Python35\lib\site-packages\django\template\utils.py:37:
RemovedInDjango110Warning: You haven't defined a TEMPLATES setting. You must
do so before upgrading to Django 1.10. Otherwise Django will be unable to
load templates.
"unable to load templates.", RemovedInDjango110Warning)
C:\django\social\mysite\urls.py:6: RemovedInDjango110Warning:
django.conf.urls.patterns() is deprecated and will be removed in Django
1.10. Update your urlpatterns to be a list of django.conf.urls.url()
instances instead.
url(r'^admin/', include(admin.site.urls)),
我尝试去那台服务器后,收到404消息。这是social / urls.py的脚本:
from django.conf.urls import patterns, url
from social import views
urlpatterns = patterns('',
# main page
url(r'^$', views.index, name='index'),
# signup page
url(r'^signup/$', views.signup, name='signup'),
# register new user
url(r'^register/$', views.register, name='register'),
# login page
url(r'^login/$', views.login, name='login'),
# logout page
url(r'^logout/$', views.logout, name='logout'),
# members page
url(r'^members/$', views.members, name='members'),
# friends page
url(r'^friends/$', views.friends, name='friends'),
# user profile edit page
url(r'^profile/$', views.profile, name='profile'),
# messages page
url(r'^messages/$', views.messages, name='messages'),
# Ajax: check if user exists
url(r'^checkuser/$', views.checkuser, name='checkuser'),
)
答案 0 :(得分:3)
更改
urlpatterns = patterns('',
...
)
到
urlpatterns = [
...
]
去除urlpatterns警告。 urlpatterns
必须是较新的Django版本中的列表。您也可以删除patterns
导入。
并将其添加到您的settings.py
:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]