小编244*_*boy的帖子

DECIMAL 类型字段取数据变成字符串

在我的表中:

我的折扣类型是 DECIMAL:

enter image description here

我在表中的数据:

enter image description here

但是为什么当我在 API 中获取数据时,会得到字符串?

enter image description here

我使用 Django/Django-Rest-Framework 作为后端。


编辑

belong_product:"?????"
ctime:"2018-04-11T15:41:15.744959+08:00"
desc: ""
discount:"0.005"
id : 1
is_enable :false
max_count:5
min_count:0
name:"???????"
uptime:"2018-04-11T15:41:15.745226+08:00"
Run Code Online (Sandbox Code Playgroud)

我的 ListAPI 视图:

class DiscountItemByUserOwnCountListAPIView(ListAPIView):
    serializer_class = DiscountItemByUserOwnCountSerializer
    permission_classes = [IsSuperAdmin]
    pagination_class = CommonPagination   
    def get_queryset(self):   
        return DiscountItemByUserOwnCount.objects.all()
Run Code Online (Sandbox Code Playgroud)

我的型号:

class DiscountItemByUserOwnCount(models.Model):
    name = models.CharField(max_length=16, help_text="??")
    desc = models.CharField(max_length=512, null=True, blank=True, help_text="??")
    min_count = models.IntegerField(help_text="???????")
    max_count = models.IntegerField(help_text="???????")  # ??~?? ????
    discount = models.DecimalField(max_digits=4, decimal_places=3, default=0.000, unique=True,
                                   help_text="??")  # ??: 0.001
    belong_product = models.CharField(max_length=16, help_text="?????DISCOUNT_PRODUCT_TYPE?????")

    is_enable …
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework

0
推荐指数
3
解决办法
1907
查看次数

如何在Python中关闭套接字连接?

我有套接字服务器和套接字客户端两个端程序:

服务器:

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
# Author:sele


import socket

HOST = '127.0.0.1'
PORT = 65432

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind((HOST, PORT))
    s.listen()
    conn, addr = s.accept()
    with conn:
        print('Connected by', addr)

        if addr and addr[0] != '127.0.0.44':
            conn.sendall(b'ip error')  # there I want to cut off the socket connection.

        else:

            while True:
                data = conn.recv(1024)
                if not data:
                    break

                conn.sendall(data)
Run Code Online (Sandbox Code Playgroud)

客户端:

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
# Author:lele

import socket

HOST = '127.0.0.1'
PORT = 65432

with …
Run Code Online (Sandbox Code Playgroud)

python sockets

0
推荐指数
1
解决办法
3万
查看次数

蓝色方块代表该项目是只读的吗?

当我使用IntelliJ IDEA打开Java项目时,项目名称中显示一个蓝色正方形:

在此处输入图片说明

那是什么意思 并且我发现我无法编辑该项目的文件,并且还显示了File is read-only

如果项目是只读的,如何使它成为可读写的?

我的Intellij IDEA版本是2019.1.3

我的项目从.jar软件包中解压缩。

java intellij-idea

0
推荐指数
1
解决办法
53
查看次数

即使导入 BIcon 也不显示引导程序图标

在我的 nuxt.js bootstrap-vue 项目中:

我按照github使用引导程序图标: 链接

我的代码:

      <b-icon variant="success" icon="arrow-up"></b-icon>
      <b-icon variant="success" icon="alert-triangle"></b-icon>

      <b-icon icon="alert-circle-fill" variant="success"></b-icon>

      <h2 class="group_title">Anime Wallpapers</h2>

...

<script>

  import { BIcon, BIconArrowUp } from 'bootstrap-vue'

  export default{
    data(){
      return {
        msg: 'hello vue'
      }
    },
    components: {
      BIcon
    }
  }
</script>
Run Code Online (Sandbox Code Playgroud)

但没有显示出来:

在此处输入图片说明

icons vue.js nuxt.js bootstrap-vue

0
推荐指数
1
解决办法
1110
查看次数