小编Coh*_*hen的帖子

Django错误--- index()缺少1个必需的位置参数:“ pk”

尝试打开路径时出现此错误。它在我的def中需要一个pk,我将其插入,但问题仍然存在。如果有人可以帮忙,我会欠你很多!

这是我在浏览器中的错误:

TypeError at /batches/
index() missing 1 required positional argument: 'pk'
Request Method: GET
Request URL:    http://127.0.0.1:8000/batches/
Django Version: 1.11.1
Exception Type: TypeError
Exception Value:    
index() missing 1 required positional argument: 'pk'
Exception Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response, line 185
Python Executable:  /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Python Version: 3.6.1
Python Path:    
['/Users/cohen/Documents/project/sanctions',
 '/Users/cohen/Documents/project/sanctions',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyObjC']
Server time:    Mon, 24 Jul 2017 10:47:02 +0000
Run Code Online (Sandbox Code Playgroud)

我的网址是成批的

from django.conf.urls import url
from . import views

urlpatterns = [
    # /batches/
    url(r'^$', views.index, name='index'), …
Run Code Online (Sandbox Code Playgroud)

python django

5
推荐指数
2
解决办法
7987
查看次数

Django 国际化 - Gettext 错误

我正在用 Django 构建一个站点。下载 gettext-0.19.8.tar.gz ---> /Users/cohen/Downloads/gettext-0.19.8 并运行所有步骤后 ./configure make 和 sudo make installation 我在安装过程中收到此错误 python manage .py makemessages -l en

在安装之前,Gettext 部分的一切都运行得很顺利。我使用的是 MAC,使用 Pycharm 作为我的 IDE。请指教!

PS有一种方法可以通过gettext安装来生成消息吗?

谢谢!

xgettext: ./venv/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/webencodings/__init__.py:1: Unknown encoding "utf8". Proceeding with ASCII instead.
xgettext: Non-ASCII string at ./venv/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/webencodings/__init__.py:64.
          Please specify the source encoding through --from-code or through a comment
          as specified in http://www.python.org/peps/pep-0263.html.
Run Code Online (Sandbox Code Playgroud)

为什么我收到这个错误。我无法使用此命令进行正确的翻译

我跟着这个培训: Django国际化最小的例子

http://www.marinamele.com/taskbuster-django-tutorial/internationalization-localization-languages-time-zones

https://gist.github.com/mbilard/1647940

后期编辑:在 virtualenv 中重新安装 gettext 后,我​​收到此错误:

make[4]: Nothing to be done for `install-exec-am'.
 ../build-aux/install-sh -c -d '/Users/cohen/PycharmProjects/gettext/share/doc/gettext/examples/build-aux'
 /usr/bin/install -c …
Run Code Online (Sandbox Code Playgroud)

python django

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

Django Admin --Bulk Staff 用户创建/从 CSV 文件导入

我有个问题。我必须从 excel/csv 文件导入我的 Django Admin 应用程序中允许的所有用户。有人可以建议,指导我如何在 Django 管理界面中实现这个东西。有我可以使用的脚本吗?他们所有人都将被允许登录我的 Django 应用程序,并且他们所有人都将自动成为员工用户。

python django admin user-defined-functions

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

Django 国际化---compilemessages 错误:AttributeError: 模块'locale' 没有属性'normalize'

我就在终点线之前,感觉我还没有完成!我创建并编译了所有消息,以便拥有一个具有 2 种语言的站点,并且在运行服务器时收到此错误:AttributeError: module 'locale' has no attribute 'normalize'。

有人可以帮帮我吗?

Traceback (most recent call last):
  File "/Users/ionutcohen/Dropbox/PycharmProjects/chn/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/ionutcohen/Dropbox/PycharmProjects/chn/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/Users/ionutcohen/Dropbox/PycharmProjects/chn/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 306, in execute
    parser = CommandParser(None, usage="%(prog)s subcommand [options] [args]", add_help=False)
  File "/Users/ionutcohen/Dropbox/PycharmProjects/chn/venv/lib/python3.6/site-packages/django/core/management/base.py", line 47, in __init__
    super().__init__(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1633, in __init__
    self._positionals = add_group(_('positional arguments'))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gettext.py", line 606, in gettext
    return dgettext(_current_domain, message)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gettext.py", line 570, in dgettext
    codeset=_localecodesets.get(domain))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gettext.py", line 505, …
Run Code Online (Sandbox Code Playgroud)

python django locale internationalization

2
推荐指数
1
解决办法
1249
查看次数

打开 CV 编解码器 FFMPEG 错误回退以使用标签 0x7634706d/'mp4v'

做一个过滤记录,一切都很好。代码正在运行,但最后视频没有保存为 MP4。我有这个错误:

OpenCV: FFMPEG: tag 0x44495658/'XVID' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
Run Code Online (Sandbox Code Playgroud)

使用 MAC 且代码运行正常,但未保存。我试图找到有关此错误的更多详细信息,但没有那么幸运。我用作编辑器 Sublime。代码在 Atom 上运行,但出现以下错误:

OpenCV: FFMPEG: tag 0x44495658/'XVID' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
2018-05-28 15:04:25.274 Python[17483:2224774] AVF: AVAssetWriter status: Cannot create file
Run Code Online (Sandbox Code Playgroud)

....

import numpy as np
import cv2
import random
from utils …
Run Code Online (Sandbox Code Playgroud)

opencv ffmpeg

2
推荐指数
1
解决办法
5731
查看次数