美文网首页
django遇到的问题及解决方法

django遇到的问题及解决方法

作者: 草中人 | 来源:发表于2017-06-06 20:46 被阅读0次

1.运行python manage.py runserver时报WinError 10013

详情:

F:\python_test_scripts\pydj_test\guest>python manage.py runserver

Performing system checks...

System check identified no issues (0 silenced).

You have 13 unapplied migration(s). Your project may not work properly until

apply the migrations for app(s): admin, auth, contenttypes, sessions.

Run 'python manage.py migrate' to apply them.

June 06, 2017 - 12:48:03

Django version 1.10.3, using settings 'guest.settings'

Starting development server at http://127.0.0.1:8000/

Quit the server with CTRL-BREAK.

Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。

分析原因:8000端口号被占用,换一个即可python manage.py  runserver  8080

2.TypeError类型错误

TypeError at /event_manage/

argument to reversed() must be a sequence

Request Method:GET

Request URL:http://127.0.0.1:8090/event_manage/

Django Version:1.10.3

Exception Type:TypeError

Exception Value:argument to reversed() must be a sequence

Exception Location:D:\WinPython-64bit-3.4.4.1\python-3.4.4.amd64\lib\site-packages\django\urls\resolvers.py in _populate, line 196

Python Executable:D:\WinPython-64bit-3.4.4.1\scripts\..\python-3.4.4.amd64\python.exe

Python Version:3.4.4

Python Path:['F:\\python_test_scripts\\pydj_test\\guest',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\python34.zip',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\DLLs',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64',

'd:\\winpython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib\\site-packages\\zope.interface-4.4.1-py3.4-win-amd64.egg',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib\\site-packages',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib\\site-packages\\pip-9.0.1-py3.4.egg',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib\\site-packages\\setuptools-33.1.1-py3.4.egg',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib\\site-packages\\win32',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib\\site-packages\\win32\\lib',

'D:\\WinPython-64bit-3.4.4.1\\python-3.4.4.amd64\\lib\\site-packages\\Pythonwin']

Server time:Tue, 6 Jun 2017 12:39:40 +0000

解决方法

是将url.py中的urlpatterns部分的{  }更改为[  ]

3.有POST方法时,提交表单报403 

具体详情:

签到时报错信息

解决方法:

在表单Form里加上{% csrf_token %}

4.test执行没说用例时,警告时间问题

F:\python_test_scripts\pydj_test\guest>python manage.py test

Creating test database for alias 'default'...

D:\WinPython-64bit-3.4.4.1\python-3.4.4.amd64\lib\site-packages\django\db\models

\fields\__init__.py:1430: RuntimeWarning: DateTimeField Event.start_time receive

d a naive datetime (2016-08-31 02:18:22) while time zone support is active.

RuntimeWarning)

..

----------------------------------------------------------------------

Ran 2 tests in 0.887s

OK

Destroying test database for alias 'default'...

解决方法:如果不需要在程序中特别处理时区(timezone-aware),在Django项目的settings.py文件中,可以直接设置为“USE_TZ = False”就省心了。

相关文章

网友评论

      本文标题:django遇到的问题及解决方法

      本文链接:https://www.haomeiwen.com/subject/rbmgfxtx.html