Tony Tan tonytan748.github.io
1.

Django数据表中增加对emoji的支持

Django项目中有一个Mysql数据表字段存储的是用户评论, 使用了系统默认的设置,导致用户提交文本中如果包含了emoji, 就会报错. 报错内容为:1django.db.utils.DataError: (1366, "Incorrect string value: '\\xF0\\x9F\\x90\\x82\\xE7\\x89...
2.

Huey as a minimal task queue for Django

This blog transfer from here Are you considering adding a task queue to your Django project? Then this article should be useful to you. When I was “younger” task queue with Djan...
3.

Django.ContentTypes使用示例

转载于这里 说明Django创建项目后,在settings.py中默认加载了以下几个app: 12345678INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.conten...
4.

[Django]queryset实现按指定字段的值进行排序

文章转载于这里 最近碰到一个需求,要对用户的学历进行排序,也就是按照[‘中专及以下’, ‘高中’, ‘大专’, ‘本科’, ‘硕士’, ‘博士’]的顺序进行排序,这就需要使用Django的ORM实现按指定字段的值进行排序。 MySQL中的SQL语句的语法: 1select * from user_education where user_id = ...
5.

后台edite页面实现三级联动

需求在项目中使用Django admin作为后台管理,在店铺表编辑页面需要设置省市区三级联动,查了很多资源,没有发现原生支持的联动方式。 在网上借鉴了别人的写法。 配置: Python 3.7 Django3.1 步骤 在app文件下创建templates文件夹,创建shop_detail.html用于复写店铺编辑页。 文件名字可自定义。 在...
6.

django2.2 build website and deploy in ubuntu server

Crete virtualenv12345678910111213pip install pipenvmkdir websitecd websitepipenv shell --python 3.6pipenv install djangopipenv install pymysqlpipenv install gunicorn when runnin...
7.

Understanding Django's Cached_property Decorator

This blog is transfer from http://ericplumb.com/blog/understanding-djangos-cached_property-decorator.html There is not a lot of documentation out there about Django’s cached_pro...