xadmin与django-rest-framework的集成(1)
什么是xadmin?什么是django-rest-framework?
xadmin是开源的一个类似于django自带的后台管理系统admin的开源模块,它基于bootstrap3框架,内置强大的插件系统,根据项目需求可以自定义扩展,它比admin功能更加丰富,更加便于我们项目的开发。
关于django-rest-framework是基于restful API标准而开发的一套针对django框架的api框架,作为目前流行的前后端分离架构,django-rest-framework通过强大的标准api接口,以及api文档自动撰写功能等对我们后端项目开发就是一种福音.
搭建开发环境
本次演示基于python3.6,django2.0(目前xadmin已经支持django2.0+)
创建虚拟环境并激活进入虚拟环境
virtualenv xadminenv
source xadminenv/bin/active
进入python环境可以看到,我们虚拟环境默认安装的python环境为3.6的
安装django,这里我们加上豆瓣源,https://pypi.douban.com/simple/
pip3 install -i https://pypi.douban.com/simple/ django
使用pip list命令可以看到,我使用的django为2.0版本
创建项目
创建项目目录
django-admin startproject myproj
项目结构如下:
myproj /
manage.py
myproj /
__init__ .py
setting.py
url.py
wsgi.PY
关于django的其它用法见我的关于django使用的文章,这里我们着重研究xadmin的使用
下面几步仅仅是为了演示需求
我们创建几个应用
python manage.py startapp users
python manage.py startapp trade
python manage.py startapp goods
python manage.py startapp user_operateion
我们在manage.py同级创建一个apps的文件夹用于存放我们的各个应用,同时创建一个extra_apps用于存放第三方包,将我们的应用放入相应的包
settings.py配置
import os
import sys # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(,os.path.join(BASE_DIR,'apps')) #将应用包加入系统变量,便于模块导入
sys.path.insert(,os.path.join(BASE_DIR,'extra_apps')) # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')57n02l@w9p9)g(47pcp6+uofk$&-a_eqburb%r2n$#w751^fa' # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users', #注册app
'goods',
'trade',
'user_operation',
]
一切就绪,编写我们的model
users/models.py
from datetime import datetime from django.db import models
from django.contrib.auth.models import AbstractUser # Create your models here. class UserProfile(AbstractUser):
"""
用户
"""
name = models.CharField(max_length=, null=True, blank=True, verbose_name="姓名")
birthday = models.DateField(null=True, blank=True, verbose_name="出生年月")
gender = models.CharField(max_length=, choices=(("male", u"男"), ("female", "女")), default="female", verbose_name="性别")
mobile = models.CharField(null=True, blank=True, max_length=, verbose_name="电话")
email = models.EmailField(max_length=, null=True, blank=True, verbose_name="邮箱") class Meta:
verbose_name = "用户"
verbose_name_plural = verbose_name def __str__(self):
return self.username class VerifyCode(models.Model):
"""
短信验证码
"""
code = models.CharField(max_length=, verbose_name="验证码")
mobile = models.CharField(max_length=, verbose_name="电话")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = "短信验证码"
verbose_name_plural = verbose_name def __str__(self):
return self.code
goos/models.py
from datetime import datetime from django.db import models
from DjangoUeditor.models import UEditorField
# Create your models here. class GoodsCategory(models.Model):
"""
商品类别
"""
CATEGORY_TYPE = (
(, "一级类目"),
(, "二级类目"),
(, "三级类目"),
) name = models.CharField(default="", max_length=, verbose_name="类别名", help_text="类别名")
code = models.CharField(default="", max_length=, verbose_name="类别code", help_text="类别code")
desc = models.TextField(default="", verbose_name="类别描述", help_text="类别描述")
category_type = models.IntegerField(choices=CATEGORY_TYPE, verbose_name="类目级别", help_text="类目级别")
parent_category = models.ForeignKey("self", null=True, blank=True, verbose_name="父类目级别", help_text="父目录",
related_name="sub_cat",on_delete=models.CASCADE)
is_tab = models.BooleanField(default=False, verbose_name="是否导航", help_text="是否导航")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = "商品类别"
verbose_name_plural = verbose_name def __str__(self):
return self.name class GoodsCategoryBrand(models.Model):
"""
品牌名
"""
category = models.ForeignKey(GoodsCategory, related_name='brands', null=True, blank=True, verbose_name="商品类目",on_delete=models.CASCADE)
name = models.CharField(default="", max_length=, verbose_name="品牌名", help_text="品牌名")
desc = models.TextField(default="", max_length=, verbose_name="品牌描述", help_text="品牌描述")
image = models.ImageField(max_length=, upload_to="brands/")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = "品牌"
verbose_name_plural = verbose_name
db_table = "goods_goodsbrand" def __str__(self):
return self.name class Goods(models.Model):
"""
商品
"""
category = models.ForeignKey(GoodsCategory, verbose_name="商品类目",on_delete=models.CASCADE)
goods_sn = models.CharField(max_length=, default="", verbose_name="商品唯一货号")
name = models.CharField(max_length=, verbose_name="商品名")
click_num = models.IntegerField(default=, verbose_name="点击数")
sold_num = models.IntegerField(default=, verbose_name="商品销售量")
fav_num = models.IntegerField(default=, verbose_name="收藏数")
goods_num = models.IntegerField(default=, verbose_name="库存数")
market_price = models.FloatField(default=, verbose_name="市场价格")
shop_price = models.FloatField(default=, verbose_name="本店价格")
goods_brief = models.TextField(max_length=, verbose_name="商品简短描述")
goods_desc = UEditorField(verbose_name=u"内容", imagePath="goods/images/", width=, height=,
filePath="goods/files/", default='')
ship_free = models.BooleanField(default=True, verbose_name="是否承担运费")
goods_front_image = models.ImageField(upload_to="goods/images/", null=True, blank=True, verbose_name="封面图")
is_new = models.BooleanField(default=False, verbose_name="是否新品")
is_hot = models.BooleanField(default=False, verbose_name="是否热销")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = '商品'
verbose_name_plural = verbose_name def __str__(self):
return self.name class IndexAd(models.Model):
category = models.ForeignKey(GoodsCategory, related_name='category',verbose_name="商品类目",on_delete=models.CASCADE)
goods =models.ForeignKey(Goods, related_name='goods',on_delete=models.CASCADE) class Meta:
verbose_name = '首页商品类别广告'
verbose_name_plural = verbose_name def __str__(self):
return self.goods.name class GoodsImage(models.Model):
"""
商品轮播图
"""
goods = models.ForeignKey(Goods, verbose_name="商品", related_name="images",on_delete=models.CASCADE)
image = models.ImageField(upload_to="", verbose_name="图片", null=True, blank=True)
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = '商品图片'
verbose_name_plural = verbose_name def __str__(self):
return self.goods.name class Banner(models.Model):
"""
轮播的商品
"""
goods = models.ForeignKey(Goods, verbose_name="商品",on_delete=models.CASCADE)
image = models.ImageField(upload_to='banner', verbose_name="轮播图片")
index = models.IntegerField(default=, verbose_name="轮播顺序")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = '轮播商品'
verbose_name_plural = verbose_name def __str__(self):
return self.goods.name class HotSearchWords(models.Model):
"""
热搜词
"""
keywords = models.CharField(default="", max_length=, verbose_name="热搜词")
index = models.IntegerField(default=, verbose_name="排序")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = '热搜词'
verbose_name_plural = verbose_name def __str__(self):
return self.keywords
trade/models.py
from datetime import datetime from django.db import models
from django.contrib.auth import get_user_model from goods.models import Goods
User = get_user_model()
# Create your models here. class ShoppingCart(models.Model):
"""
购物车
"""
user = models.ForeignKey(User, verbose_name=u"用户",on_delete=models.CASCADE)
goods = models.ForeignKey(Goods, verbose_name=u"商品",on_delete=models.CASCADE)
nums = models.IntegerField(default=, verbose_name="购买数量") add_time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间") class Meta:
verbose_name = '购物车'
verbose_name_plural = verbose_name
unique_together = ("user", "goods") def __str__(self):
return "%s(%d)".format(self.goods.name, self.nums) class OrderInfo(models.Model):
"""
订单
"""
ORDER_STATUS = (
("TRADE_SUCCESS", "成功"),
("TRADE_CLOSED", "超时关闭"),
("WAIT_BUYER_PAY", "交易创建"),
("TRADE_FINISHED", "交易结束"),
("paying", "待支付"),
) user = models.ForeignKey(User, verbose_name="用户",on_delete=models.CASCADE)
order_sn = models.CharField(max_length=, null=True, blank=True, unique=True, verbose_name="订单号")
trade_no = models.CharField(max_length=, unique=True, null=True, blank=True, verbose_name=u"交易号")
pay_status = models.CharField(choices=ORDER_STATUS, default="paying", max_length=, verbose_name="订单状态")
post_script = models.CharField(max_length=, verbose_name="订单留言")
order_mount = models.FloatField(default=0.0, verbose_name="订单金额")
pay_time = models.DateTimeField(null=True, blank=True, verbose_name="支付时间") # 用户信息
address = models.CharField(max_length=, default="", verbose_name="收货地址")
signer_name = models.CharField(max_length=, default="", verbose_name="签收人")
singer_mobile = models.CharField(max_length=, verbose_name="联系电话") add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = u"订单"
verbose_name_plural = verbose_name def __str__(self):
return str(self.order_sn) class OrderGoods(models.Model):
"""
订单的商品详情
"""
order = models.ForeignKey(OrderInfo, verbose_name="订单信息", related_name="goods",on_delete=models.CASCADE)
goods = models.ForeignKey(Goods, verbose_name="商品",on_delete=models.CASCADE)
goods_num = models.IntegerField(default=, verbose_name="商品数量") add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = "订单商品"
verbose_name_plural = verbose_name def __str__(self):
return str(self.order.order_sn)
user_operation/models.py
from datetime import datetime from django.db import models
from django.contrib.auth import get_user_model from goods.models import Goods
# Create your models here.
User = get_user_model() class UserFav(models.Model):
"""
用户收藏
"""
user = models.ForeignKey(User, verbose_name="用户",on_delete=models.CASCADE)
goods = models.ForeignKey(Goods, verbose_name="商品", help_text="商品id",on_delete=models.CASCADE)
add_time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间") class Meta:
verbose_name = '用户收藏'
verbose_name_plural = verbose_name
unique_together = ("user", "goods") def __str__(self):
return self.user.username class UserLeavingMessage(models.Model):
"""
用户留言
"""
MESSAGE_CHOICES = (
(, "留言"),
(, "投诉"),
(, "询问"),
(, "售后"),
(, "求购")
)
user = models.ForeignKey(User, verbose_name="用户",on_delete=models.CASCADE)
message_type = models.IntegerField(default=, choices=MESSAGE_CHOICES, verbose_name="留言类型",
help_text=u"留言类型: 1(留言),2(投诉),3(询问),4(售后),5(求购)")
subject = models.CharField(max_length=, default="", verbose_name="主题")
message = models.TextField(default="", verbose_name="留言内容", help_text="留言内容")
file = models.FileField(upload_to="message/images/", verbose_name="上传的文件", help_text="上传的文件")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = "用户留言"
verbose_name_plural = verbose_name def __str__(self):
return self.subject class UserAddress(models.Model):
"""
用户收货地址
"""
user = models.ForeignKey(User, verbose_name="用户" ,on_delete=models.CASCADE)
province = models.CharField(max_length=, default="", verbose_name="省份")
city = models.CharField(max_length=, default="", verbose_name="城市")
district = models.CharField(max_length=, default="", verbose_name="区域")
address = models.CharField(max_length=, default="", verbose_name="详细地址")
signer_name = models.CharField(max_length=, default="", verbose_name="签收人")
signer_mobile = models.CharField(max_length=, default="", verbose_name="电话")
add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta:
verbose_name = "收货地址"
verbose_name_plural = verbose_name def __str__(self):
return self.address
模型编写完成,设置一下我们的数据库配置,我这里使用mysql
myproj/settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproj',
'USER':'root',
'PASSWORD':'',
'HOST':'localhost',
'POSRT':'',
'OPTIONS': {
'init_command': 'SET default_storage_engine=INNODB',
}
}
}
AUTH_USER_MODEL = 'users.UserProfile' #由于我们在users/models.py继承了django的AbstractUser,所以需要在settings.py中指定我们自定义的user模型,否则创建模型会报E304错误
执行以下命令,生成我们的数据库迁移脚本并生成数据库模型
python manage.py makemigrations
python mange.py migrate
如果报错,显示以下错误信息
因为我们未安装数据库连接驱动
pip3 install -i https://pypi.douban.com/simple/ mysqlclient
编辑myproj/__init__.py
import pymysql pymysql.install_as_MySQLdb() #因为mysqldb不支持3.5及以上版本,这里我们使用pymysql,这句话意思是将pymysql包传入mysqldb进行初始化
此时仍然报错,因为我们在创建goods/models.py里面的模型时候,使用了DjangoUeditorapp,但我们实际上还未导入这个包,因为这个属于第三方包,我们使用源码导入,并将其放置在extra_apps目录下,源码下载路径:http://ueditor.baidu.com/website/
在myproj/settings.py中注册此app
此时再执行数据库迁移命令,如下
此时,数据库迁移模型已经生成,我们只需再执行migrate命令同步数据库即可
此时数据库中已经有我们的数据表模型了
以上步骤都完成以后就可以开始着手创建系统管理后台了,关于django自带的admin这里不再阐述,我们直接开始xadmin的集成
xadmin的集成
导入xadmin,这里我们选择源码导入,https://github.com/sshwsfc/xadmin/tree/django2下载django2对应的源码到本地,将xadmin文件夹整体拷贝到我们的extra_apps目录下,并在settings.py文件中注册
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users', #注册app
'goods',
'trade',
'user_operation',
'DjangoUeditor',
'xadmin' #注册xadmin
]
根据xadmin源码,由于xadmin模块需要依赖其它包,我们在这里一一安装
pip3 install -i https://pypi.douban.com/simple/ django-crispy-forms>=1.6.0 django-import-export>=0.5.1 django-reversion>=2.0.0 django-formtools==2.0 future==0.15.2 httplib2==0.9.2 six==1.10.0
在settings.py中注册crispy_forms
创建超级管理员
python manage.py createsuperuser
配置xadminurl
import xadmin urlpatterns = [
# url('admin/', admin.site.urls),
re_path(r'xadmin/',xadmin.site.urls)
]
配置完之后,需要同步以下数据库,生成xadmin需要的数据库表
此时,运行项目,访问,localhost:8000/xadmin
至此,我们的xadmin后台就初步搭建完成了,下面我们注册我们的各个app项目
在之前apps下面的app中分别创建adminx.py文件,里面用来定义xadmin的定制类
users/adminx.py
#!/usr/bin/env python
# encoding: utf- import xadmin
from xadmin import views
from .models import VerifyCode class BaseSetting(object):
enable_themes = True
use_bootswatch = True class GlobalSettings(object):
site_title = "后台管理" #设置头标题
site_footer = "shopping center" #设置脚标题
# menu_style = "accordion" class VerifyCodeAdmin(object):
list_display = ['code', 'mobile', "add_time"] xadmin.site.register(VerifyCode, VerifyCodeAdmin)
xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSettings)
goos/adminx.py
#!/usr/bin/env python
# encoding: utf-
import xadmin
from .models import Goods, GoodsCategory, GoodsImage, GoodsCategoryBrand, Banner, HotSearchWords
from .models import IndexAd class GoodsAdmin(object):
list_display = ["name", "click_num", "sold_num", "fav_num", "goods_num", "market_price",
"shop_price", "goods_brief", "goods_desc", "is_new", "is_hot", "add_time"]
search_fields = ['name', ]
list_editable = ["is_hot", ]
list_filter = ["name", "click_num", "sold_num", "fav_num", "goods_num", "market_price",
"shop_price", "is_new", "is_hot", "add_time", "category__name"]
style_fields = {"goods_desc": "ueditor"} class GoodsImagesInline(object):
model = GoodsImage
exclude = ["add_time"]
extra =
style = 'tab' inlines = [GoodsImagesInline] class GoodsCategoryAdmin(object):
list_display = ["name", "category_type", "parent_category", "add_time"]
list_filter = ["category_type", "parent_category", "name"]
search_fields = ['name', ] class GoodsBrandAdmin(object):
list_display = ["category", "image", "name", "desc"] def get_context(self):
context = super(GoodsBrandAdmin, self).get_context()
if 'form' in context:
context['form'].fields['category'].queryset = GoodsCategory.objects.filter(category_type=)
return context class BannerGoodsAdmin(object):
list_display = ["goods", "image", "index"] class HotSearchAdmin(object):
list_display = ["keywords", "index", "add_time"] class IndexAdAdmin(object):
list_display = ["category", "goods"] xadmin.site.register(Goods, GoodsAdmin)
xadmin.site.register(GoodsCategory, GoodsCategoryAdmin)
xadmin.site.register(Banner, BannerGoodsAdmin)
xadmin.site.register(GoodsCategoryBrand, GoodsBrandAdmin) xadmin.site.register(HotSearchWords, HotSearchAdmin)
xadmin.site.register(IndexAd, IndexAdAdmin)
trade/adminx.py
# -*- coding: utf- -*-
__author__ = 'bobby' import xadmin
from .models import ShoppingCart, OrderInfo, OrderGoods class ShoppingCartAdmin(object):
list_display = ["user", "goods", "nums", ] class OrderInfoAdmin(object):
list_display = ["user", "order_sn", "trade_no", "pay_status", "post_script", "order_mount",
"order_mount", "pay_time", "add_time"] class OrderGoodsInline(object):
model = OrderGoods
exclude = ['add_time', ]
extra =
style = 'tab' inlines = [OrderGoodsInline, ] xadmin.site.register(ShoppingCart, ShoppingCartAdmin)
xadmin.site.register(OrderInfo, OrderInfoAdmin)
user_operation/adminx.py
#!/usr/bin/env python
# encoding: utf-
import xadmin
from .models import UserFav, UserLeavingMessage, UserAddress class UserFavAdmin(object):
list_display = ['user', 'goods', "add_time"] class UserLeavingMessageAdmin(object):
list_display = ['user', 'message_type', "message", "add_time"] class UserAddressAdmin(object):
list_display = ["signer_name", "signer_mobile", "district", "address"] xadmin.site.register(UserFav, UserFavAdmin)
xadmin.site.register(UserAddress, UserAddressAdmin)
xadmin.site.register(UserLeavingMessage, UserLeavingMessageAdmin)
到此,我们的项目app都已经集成到xadmin后台中,至于xadmin自定义字段表示的意思,可以查询相关文档
xadmin与django-rest-framework的集成(1)的更多相关文章
- [Django REST framework - RBAC-基于角色的访问控制、base64编码 、xadmin的使用]
[Django REST framework - RBAC-基于角色的访问控制.base64编码 .xadmin的使用] RBAC-基于角色的访问控制 RBAC 是基于角色的访问控制(Role-Bas ...
- Django REST framework+Vue 打造生鲜超市(一)
一.项目介绍 1.1.掌握的技术 Vue + Django Rest Framework 前后端分离技术 彻底玩转restful api 开发流程 Django Rest Framework 的功能实 ...
- Django REST framework+Vue 打造生鲜超市(四)
五.商品列表页 5.1.django的view实现商品列表页 (1)goods/view_base.py 在goods文件夹下面新建view_base.py,为了区分django和django res ...
- 3- vue django restful framework 打造生鲜超市 - model设计和资源导入
3- vue django restful framework 打造生鲜超市 - model设计和资源导入 使用Python3.6与Django2.0.2(Django-rest-framework) ...
- 1- vue django restful framework 打造生鲜超市
Vue+Django REST framework实战 使用Python3.6与Django2.0.2(Django-rest-framework)以及前端vue开发的前后端分离的商城网站 项目支持支 ...
- Vue+Django REST framework打造生鲜电商项目
1-1 课程导学 2-1 Pycharm的安装和简单使用 2-2 MySQL和Navicat的安装和使用 2-3 Windows和Linux下安装Python2和Python3 2-4 虚拟环境的安装 ...
- Django序列化&django REST framework
第一章.Django序列化操作 1.django的view实现商品列表页(基于View类) # 通过json来序列化,但手写字典key代码量较大,容易出错:还有遇到时间,图片序列化会报错 from g ...
- Django REST framework+Vue 打造生鲜超市(三)
四.xadmin后台管理 4.1.xadmin添加富文本插件 (1)xadmin/plugins文件夹下新建文件ueditor.py 代码如下: # xadmin/plugins/ueditor.py ...
- Django REST framework+Vue 打造生鲜超市(五)
六.商品类别数据展示 6.1. 商品类别数据接口 (1)商品分类有两个接口: 一种是全部分类:一级二级三级 一种是某一类的分类以及商品详细信息: 开始写商品分类的接口 (2)序列化 给分类添加三级分类 ...
- Python3+PyCharm+Django+Django REST framework开发教程
一.说明 自己一是想跟上潮流二是习惯于直接干三是没有人可以请教,由于这三点经常搞得要死要活.之前只简单看过没写过Diango,没看过Django REST framework,今天一步到位直接上又撞上 ...
随机推荐
- 【iCore4 双核心板_FPGA】例程十五:基于单口RAM的ARM+FPGA数据存取实验
实验现象: 写RAM命令格式:write:地址(0-255),数据(0-65535)\cr\lf 读RAM命令格式:read:地址(0-255)\cr\lf 核心代码: int main(void) ...
- Spring Security 指定登陆入口
spring security除通过form-login的熟悉指定登陆还可以通过entry-point-ref 指定登陆入口.具体配置如下: <?xml version="1.0&qu ...
- hbase源码系列(十五)终结篇&Scan续集-->如何查询出来下一个KeyValue
这是这个系列的最后一篇了,实在没精力写了,本来还想写一下hbck的,这个东西很常用,当hbase的Meta表出现错误的时候,它能够帮助我们进行修复,无奈看到3000多行的代码时,退却了,原谅我这点自私 ...
- Java知多少(43)异常处理基础
Java异常是一个描述在代码段中发生的异常(也就是出错)情况的对象.当异常情况发生,一个代表该异常的对象被创建并且在导致该错误的方法中被抛出(throw).该方法可以选择自己处理异常或传递该异常.两种 ...
- 如何解决安装VMware后郑广电宽带客户端不能登录的问题?
如何解决安装VMware后郑广电宽带客户端不能登录的问题? 问题:安装VMware后,郑广电宽带客户端不能登录,提示:“不允许代理上网”. 解决:将VMware的虚拟网卡(VMnet1和VMnet8) ...
- 关于HTTP请求返回417 “Expectation Failed”
在使用HttpClient默认情况下做POST的时候, HttpClient并不会直接就发起POST请求, 而是会分为俩步, 1.发送一个请求, 包含一个Expect:100-continue, 询问 ...
- windows下添加多个git仓库账号
当使用git方式下载时,如果没有配置过ssh key,会提示错误(git clone支持https和git(即ssh)两种方式下载源码) 当需要在机器上使用不同的git账户,这就需要知道如何在机器上添 ...
- Mac 上 Charles 抓取 iso http、https数据包
一.下载charles包. http://www.charlesproxy.com/download/ 选择mac版本的最新包Charles is 3.11.4. http://www.charles ...
- [Linux] 设置系统时区
1. 检查当前时区 以 root 身份登录. # date Fri Sep :: UTC 其中 UTC 是指当前使用的时间系统为世界标准时间,也称世界协调时间.英文名称为 Coordinated Un ...
- 128、View 绘制流程 & 自定义View
记清楚函数调用的顺序才能准确地进行调用. 根据调用链,可将整个绘制过程分为三部分:Measure - Layout - Draw Measure 过程 1. 测量过程由上至下,在measure过程的最 ...