小编Pov*_*asK的帖子

Django Shell图片上传_io.BufferedReader无属性大小

我的问题是,当我尝试使用 Django shell 将图像保存到我的模型时,我收到此错误,我无法找到任何解决方案。

模型.py

class AdImage(models.Model):
   ad = models.ForeignKey(Ad)
   full_photo = models.ImageField(upload_to='uploads/', blank=True)
Run Code Online (Sandbox Code Playgroud)

我导入模型创建 AdImage 实例添加 'ad' 并尝试

imagead.full_photo.save("NowHiring.jpg",open("C:\\NowHiring.jpg", "rb"))
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\hp\Envs\platform\lib\site-packages\django\db\models\fields\file
s.py", line 106, in save
    self._size = content.size
AttributeError: '_io.BufferedReader' object has no attribute 'size'
Run Code Online (Sandbox Code Playgroud)

使用:Python 3.5,Django 1.9

我能做什么 ?

python django shell

5
推荐指数
1
解决办法
4178
查看次数

为什么 pytesseract 无法识别这张简单图像中的数字?

我正在尝试使用 pytesseract 从图像中识别两个数字:

在此处输入图片说明

  • 我已经尝试--psm 610
  • 我试过了 -c tessedit_char_whitelist=0123456789'

以上都不返回49数字。我得到的最接近的返回4没有9

你有关于如何让tesseract识别它的任何提示吗?

python ocr tesseract python-tesseract

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

VsCode Exception has occurred: VariableDoesNotExist

VS Code throws exception when using debugger to run Django.

I got the same problem on two different projects that were working fine before. I can't recall any changes that would lead to this exception. It occurs when I try to open Django admin page.

Exception:

Exception has occurred: VariableDoesNotExist
Failed lookup for key [is_popup] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: '1XjSoBrvAaFZuOY9WTme5tXLO8awl43ORBO5YolUoHOlM0nOLDAfGd0atO3kh3dI'>, 'debug': True, 'sql_queries': <function debug.<locals>.<lambda> at 0x109638c80>, 'request': <WSGIRequest: GET '/login/?next=/'>, 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object …
Run Code Online (Sandbox Code Playgroud)

django visual-studio-code

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