我在虚拟环境包装器中运行python,我尝试导入UUID.以下是我收到的内容:
python -v
>>> import uuid
# /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/site-packages/uuid.pyc matches /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/site-packages/uuid.py
import uuid # precompiled from /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/site-packages/uuid.pyc
import ctypes # directory /usr/lib/python2.7/ctypes
# /usr/lib/python2.7/ctypes/__init__.pyc matches /usr/lib/python2.7/ctypes/__init__.py
import ctypes # precompiled from /usr/lib/python2.7/ctypes/__init__.pyc
dlopen("/home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_ctypes.dll", 2);
import _ctypes # dynamically loaded from /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_ctypes.dll
# /usr/lib/python2.7/struct.pyc matches /usr/lib/python2.7/struct.py
import struct # precompiled from /usr/lib/python2.7/struct.pyc
dlopen("/home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_struct.dll", 2);
import _struct # dynamically loaded from /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_struct.dll
# /usr/lib/python2.7/ctypes/_endian.pyc matches /usr/lib/python2.7/ctypes/_endian.py
import ctypes._endian # precompiled from /usr/lib/python2.7/ctypes/_endian.pyc
# /usr/lib/python2.7/ctypes/util.pyc matches /usr/lib/python2.7/ctypes/util.py
import ctypes.util # precompiled from /usr/lib/python2.7/ctypes/util.pyc
Run Code Online (Sandbox Code Playgroud)
之后,python停止,没有任何其他警告.我试图从Cygwin重新安装该库,但这没有帮助. …
我正在使用Django Rest Framework来序列化我有一个外键的模型.
models.py
class Article(models.Model):
author = models.ForeignKey(Author, related_name='articles')
... other fields...
Run Code Online (Sandbox Code Playgroud)
serializers.py
class ArticleSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Article
Run Code Online (Sandbox Code Playgroud)
我想摆脱可浏览的API视图底部的'HTML表单',因为我得到了一个包含我所有文章的列表并从数据库中检索它们需要很长时间(我有一些100K文章,每次html表单都是显示,我的服务器执行100K查询).
我已经阅读了如何禁用django-rest-framework的管理式可浏览界面的答案?我目前正在JSON中显示视图.但是,我喜欢html视图,并希望找到一种方法来避免底部提供的html表单.
我不想从视图中正确删除该字段(我需要使用它),但只是删除用于填充表单的数据库查询.
任何的想法 ?