django 笔记

最好的资料就是官网文档:

1、tutorial

英文

https://docs.djangoproject.com/en/2.0/intro/

中文翻译

http://django-intro-zh.readthedocs.io/zh_CN/latest/

用pycharm开发django,也是tutorial例子

https://www.jetbrains.com/help/pycharm/creating-and-running-your-first-django-project.html

然后就是2、topic

https://docs.djangoproject.com/en/2.0/topics/

可以选择自己需求的读

慕课网这个也可以看看,不过是收费的。

https://coding.imooc.com/class/chapter/78.html#Anchor

Django version   Python versions

1.11                 2.7, 3.4, 3.5, 3.6

2.0                   3.4, 3.5, 3.6

2.1                 3.5, 3.6, 3.7

1.11是最后一个支持python2.7的版本,后续都是python 3x

我这里用:

python 3.6 和 django 2.0.6

安装后添加这两个到PATH

image

修改语言和时区

LANGUAGE_CODE = 'zh-Hans'

TIME_ZONE = 'Asia/Shanghai'

模板中url自动生成

定义命名空间

app_name = 'polls' 

代码中用 path中的name定义url名字

path('<int:question_id>/', views.detail, name='detail')

模板中用 url template tag来访问

<li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>

用app_name 


pycharm 添加try except代码块
https://www.jetbrains.com/help/pycharm/surrounding-blocks-of-code-with-language-constructs.html



还有一些学习参考链接:
https://www.jianshu.com/p/b9fdc977bb96
http://www.tangowithdjango.com/


posted on 2018-06-14 17:20  katago  阅读(219)  评论(0编辑  收藏  举报