我目前正在使用Django开发API.
但是,我想创建一个视图,使用以下端点返回当前用户:/users/current/.
为此,我创建了一个列表视图,并将查询集过滤到发出请求的用户.这是有效的,但结果是一个列表,而不是一个对象.结合分页,结果看起来太复杂,与其他端点不一致.
我还试图创建一个详细视图并过滤查询集,但DRF抱怨我没有提供pk或slug.
你有什么主意吗 ?
有人知道ConcurrentHashMap的内存开销是什么(与"经典"HashMap相比)?
我的问题很简单,但我真的不知道它的名字,因此,很难找到自己的解决方案:如何简化依赖图(如(->取决于)):
A - > B - > C&A - > C.
至
A -> B -> C
Run Code Online (Sandbox Code Playgroud) 我想随时保持光标居中.
我管理,感谢这个Vim Tips页面scrolloff上提到的高价值,当光标周围有线时保持居中,但当光标靠近第一行或最后一行时,我无法使Vim表现那样.有可能让Vim添加"波浪线"来代替"真实线条"吗?~
我目前正在概述C++ 11的新功能,并且由于目前尚未理解的原因,其中一些不能编译.我使用gcc版本4.6.0 20100703(实验性)(GCC),因此根据GNU GCC常见问题解答,我支持所有功能.我尝试使用std = c ++ 0x和std = gnu ++ 0x标志进行编译.
例如,我不想在一段代码中使用非成员begin()和end():
#include <iostream>
#include <map>
#include <utility>
#include <iterator>
using namespace std;
int main ( ) {
map < string, string > alias;
alias.insert ( pair < string, string > ( "ll", "ls -al" ) );
// ... Other inserts
auto it = begin(alias);
while ( it != end(alias) ) {
//...
}
Run Code Online (Sandbox Code Playgroud)
我明白了,
nonMemberBeginEnd//main.cc:15:24: error: ‘begin’ was not declared in this scope
nonMemberBeginEnd//main.cc:15:24: error: …Run Code Online (Sandbox Code Playgroud) 我使用Spring Data Rest 2.1.1 Release和默认配置.考虑以下资源:
GET /communities/MyCommunity
{
"creationDate": "2014-07-16T06:22:37.153+0000",
"name": "GroupeSEB",
"_links": {
"self": {
"href": "http://localhost:8080/api/communities/GroupeSEB"
},
"posts": {
"href": "http://localhost:8080/api/communities/GroupeSEB/posts"
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我得到"帖子"子资源时:
GET /communities/MyCommunity/posts
{
"_embedded": {
"posts": [
{
"creationDate": "2014-07-09T13:09:14.535+0000",
"id": "53bd3efae4b012818368c549",
"_links": {
"self": {
"href": "http://localhost:8080/api/posts/53bd3efae4b012818368c549"
}
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
没有启用分页.由于我的父资源可以聚合大量帖子(其子资源),我如何为每个子资源启用分页?
Git有多少个命令?特别是 :
可选:命令有多少平均标志?