Django学习Tips *部分踩坑总结
在踩了无数坑后爬过来~记录自己的学习tips~
使用django1.10 python2.7
0.学习资源
Tango with Django 中文文档: http://hackerxu.com/Twd/
官方文档:https://docs.djangoproject.com/en/1.10/BAE部署Django项目流程整理:http://www.cnblogs.com/calmman/p/6265655.html
centos6下部署django环境:http://blog.chinaunix.net/uid-531464-id-4767884.html
http://blog.everlose.com/set-up-python-on-centos.html
http://www.cnblogs.com/xz1024/p/6134359.html
http://www.wtoutiao.com/p/2b0B7LT.html
http://blog.csdn.net/zhyh1435589631/article/details/51946439
helloworld教程:http://blog.csdn.net/zez11/article/details/52253488
http://blog.csdn.net/LABLENET/article/details/53321260
http://www.cnblogs.com/lhj588/archive/2012/02/17/2356478.html
https://www.cnhzz.com/django-basic-command/
http://blog.csdn.net/donggege214/article/details/51648304
1.rom django.conf.urls import * 找不到patterns模块
django 1.10 已经移除此特性
2.保存并同步数据库
Python manage.py syncdb
3.使用Django生成Model
python manage.py inspectdb
4.汉化
django1.9以上 注意不同系统下_与-
LANGUAGE_CODE = ‘zh_Hans’
5.连接MySql乱码问题
关于修改my.ini:http://blog.csdn.net/red4711/article/details/6007248
深坑。。就算输入show variables like ‘character%’;
出来的全是utf8也没用
请用:
CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
来建表。。辛酸脸orz
6.创建管理员用户名密码
python manage.py migrate
python manage.py shell
from django.contrib.auth.models import User
user=User.objects.create_superuser(‘用户名’,’邮箱’,’密码’)
7.实现分页
使用Paginator实现分页功能 :https://mozillazg.com/2013/01/django-pagination-by-use-paginator.html
文档:https://docs.djangoproject.com/en/1.10/topics/pagination/