V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  metamask  ›  全部回复第 21 页 / 共 27 页
回复总数  524
1 ... 13  14  15  16  17  18  19  20  21  22 ... 27  
2019 年 6 月 27 日
回复了 sailorlisa 创建的主题 Python Python Django 中对于 makemigrations 命令的疑问
make / migrations
顾名思义,就是你说的几点;

实现的话,可以看下这 2 个文件
django/db/migrations/autodetector.py
django/db/migrations/writer.py
2019 年 6 月 5 日
回复了 datou 创建的主题 Python v2 的诸位,你们写 Python 的时候会在 if 语句加上圆括号吗?
2019 年 6 月 5 日
回复了 datou 创建的主题 Python v2 的诸位,你们写 Python 的时候会在 if 语句加上圆括号吗?
PEP8 不支持这种做法吧?

如果 if 判断太长的话,拆成多个再 if 拼接
2019 年 5 月 31 日
回复了 ouou8 创建的主题 程序员 网站能检测到我查看它的源码? 怎么做到的
@atom234 #33

(function() {var a = new Date(); debugger; return new Date() - a > 100;}())
2019 年 5 月 27 日
回复了 chaleaochexist 创建的主题 Python 采访一下,django channel 现在用的多么?
2 年前用过, 当时做很小的活动 h5 游戏(websocket),感觉还可以。
2019 年 5 月 20 日
回复了 13192262269 创建的主题 程序员 有什么好看有死贵死贵的那种双肩包?●ω●
everlane
如果更复杂的情况,

如果是基本业务代码相同,可以考虑做成 parent view 然后继承;
如果是业务代码共用,需要做部分处理,那么在类内做成 base func,用*kwarg 来做处理,

代码相对来说可能比较漂亮些;

另外作为 drf 吹( django rest framework ),推荐你使用。
感觉有些乱来

view 的作用是处理 request response, 没必要这么引用

如果 A 和 B 有代码可以共用,那么就抽出来做个 Mxin 就可以,没必要交叉

随便改了下,类似这样
https://gist.github.com/chrisguox/4de1a0cc586055d776be818ed636cf6e
2019 年 5 月 13 日
回复了 KevinBu 创建的主题 Python Django 如何一次查询 3 张表?
第一种办法
1 分别查询
2 用 chains 连接起来
3 如果是 drf,建个自定义 serializer 序列化

------

第二种
重新抽象 model,
看业务需求用 proxy 模式或者直接用字段表示不同的类型,再分别 filter 出去
@mashoushan1989

[更多公司介绍请点此]( http:https://ashma.info/2019/03/01/Q&A-of-hiring/?v2ex)

http:https://
是主题的链接加多了协议头
2019 年 4 月 10 日
回复了 imherer 创建的主题 程序员 JWT 如何实现一个账号只能同时在一个设备(端)登录
如果是 drf 那套的话,
login 的时候直接把 token 更新下就可以。


jwt 的过期和刷新的理念,当时用的时候觉得不太顺手,git 上面好像还有一个 issue 就是讨论这个问题。
2019 年 4 月 8 日
回复了 anonymoustian 创建的主题 Python Python 如何提取非结构化数据
content = "ad=0 cd=0 rcode=ok qdcount=1 ancount=0 nscount=0 arcount=1 src=232.190.252.222 dst=45.80.170.1 test test2"

1
直接字符串判断
rocde_is_ok = "rcode=ok"
rocde_is_ok in content

2

pairs = content.split(' ')

content_dict = {}
for name_value in pairs:
nv = name_value.split('=', 1)
if len(nv) != 2:
nv.append("")

key, value = nv
content_dict[key] = value
2019 年 3 月 28 日
回复了 Orenoid 创建的主题 程序员 问个 RESTful API 设计的问题
Patch /path/to/resource/<id>/

data :
{
"a" : "test",
"b": "test"
}

----
Patch /path/to/resource/<id>/

data :
{
"b" : "test",
"c": "test"
}


在渲染层再做业务的处理
self.website =
这行结尾多了一个逗号
CRUD
1 ... 13  14  15  16  17  18  19  20  21  22 ... 27  
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2672 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 29ms · UTC 15:23 · PVG 23:23 · LAX 08:23 · JFK 11:23
♥ Do have faith in what you're doing.