更新:关于此问题的Open Open:24272
什么都有关系?
Django有一个GenericRelation类,它增加了一个"反向"泛型关系来启用一个额外的API.
事实证明我们可以使用它reverse-generic-relation
,filtering
或者ordering
我们不能在里面使用它prefetch_related
.
我想知道这是一个错误,或者它不应该工作,或者它可以在功能中实现的东西.
让我用一些例子告诉你我的意思.
让我们说我们有两个主要模型:Movies
和Books
.
Movies
有一个 Director
Books
有一个 Author
我们要的标签分配给我们的Movies
和Books
,但是,而是采用MovieTag
和BookTag
模型,我们想用一个单一的TaggedItem
与类GFK
到Movie
或Book
.
这是模型结构:
from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType
class TaggedItem(models.Model):
tag = models.SlugField()
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id') …
Run Code Online (Sandbox Code Playgroud) 我希望能够pdb
在uWSGI下调试Python(Django)应用程序,并且我基本上遇到了与此处描述相同的问题:
...
File "/usr/lib/python2.7/bdb.py", line 49, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/lib/python2.7/bdb.py", line 68, in dispatch_line
if self.quitting: raise BdbQuit
BdbQuit
Run Code Online (Sandbox Code Playgroud)
不同的是,我有不同的uWSGI
设置,好像我不能让uWSGI
以honour-stdin
作为从上面的问题接受的答案建议.
我的设置如下:
1)我有一个systemd进程在Emperor模式下启动uWSGI
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStart=/usr/local/bin/uwsgi --ini /etc/uwsgi/emperor.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
2)/etc/uwsgi/emperor.ini
看起来像这样:
[uwsgi]
emperor = /etc/uwsgi/sites
uid = www-data
gid = www-data
limit-as = 1024
logto = /tmp/uwsgi-emperor.log
# I've tried adding both honour-stdin
# and daemons-honour-stdin here
honour-stdin = true …
Run Code Online (Sandbox Code Playgroud)