See here are some modules in alphabetical order by default in the admin sidebar
Authentication and Authorization Data/Questions/Surveys/Website admin
I want to rearrange the order how can I do that. ? I know in the Django world it does not matter. But our client requested to do that. So we need help with how we can do that.
我有一个带有数字的对象数组,但类型是 string ,我想将它们全部相加。
按照之前建议的堆栈溢出答案,我正在这样做。
// Here the data has an array of goods which contains
// amount objects and i want to calculate to sum of amount objects
Total Invoice Price:
{data.goods
? data.goods.map((item) => (
<div key={item.id}>
<div>{parseInt(item.amount).reduce((a, b) => a + b, 0)}</div>
</div >
))
: null}
Run Code Online (Sandbox Code Playgroud)
但我收到错误TypeError: parseInt(...).reduce is not a function,如何解决这个问题?
我正在尝试获取嵌套数组的总和。数组结构是这样的:
const arr = [
{ question: 'A', parentId: 1, weightage: 10, child: [] },
{
question: 'B',
parentId: 4,
weightage: 0,
child: [{ id: 4, sub_question: 'X', weightage: 55 }]
},
{ question: 'C', parentId: 5, weightage: 20, child: [] }
]
Run Code Online (Sandbox Code Playgroud)
在这里您可以看到一个问题,然后是一个带有子问题的子数组。两者都有一个名为权重的键。我想将所有权重值计算为总和。
我正在使用这种方法
const sum = (value, key) => {
if (!value || typeof value !== 'object') return 0
if (Array.isArray(value)) return value.reduce((t, o) => t + sum(o, key), 0)
if (key in value) return value[key]
return sum(Object.values(value), …Run Code Online (Sandbox Code Playgroud) 我需要修改nginx.conf来增加client_max_body_size . 在 AWS 文档上。这里他们给出了如何修改配置的示例。但他们做了很多我不想做的事情。
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-nginx.html
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 33282;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
include conf.d/*.conf;
map $http_upgrade $connection_upgrade {
default "upgrade";
}
server {
listen 80 default_server;
root /var/app/current/public;
location / {
}git pull
location /api {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host; …Run Code Online (Sandbox Code Playgroud) 我有一个返回布尔值的对象列表,如下所示
badges = [{"is_staff": self.sender.is_staff},
{"is_vendor": self.sender.is_vendor}, {"is_trader": self.sender.is_trader}]
# or we can write this like that;
badges = [{"is_staff": True}, {"is_vendor": False}, {"is_trader": True}]
Run Code Online (Sandbox Code Playgroud)
我想以这个优先级返回用户徽章;is_staff 具有最高优先级,然后是供应商,然后是交易者。
如果用户拥有所有徽章,那么我只想将 is_staff 的徽章作为字符串值返回到 = 'staff',因为它具有最高优先级。
喜欢
badge = 'staff'
Run Code Online (Sandbox Code Playgroud)
我有这个功能可以使用。但没有找到返回我想要的值的方法。
@property
def badge(self):
"Returns the user's designation if the user is Staff, Vendor, Trader."
badges = [{"is_staff": self.sender.is_staff},
{"is_vendor": self.sender.is_vendor}, {"is_trader": self.sender.is_trader}]
badge = ''
# need help there to find the value on the basis of badges
return badge
Run Code Online (Sandbox Code Playgroud)