【问题标题】:django-notification emit_notices extra sql queries?django-notification emit_notices 额外的 sql 查询?
【发布时间】:2012-04-16 05:54:31
【问题描述】:

所以我一直在试图弄清楚为什么 django-notification emit_notices 会打印出多个不需要对我的通知队列做任何事情的额外查询

我在解释器中运行:

notification.queue([to_user], "new_msg", {"from_user": from_user}, sender=from_user)

然后

python manage.py emit_notices

------------------------------------------------------------------------
acquiring lock...
acquired.
(0.001) SELECT `notification_noticequeuebatch`.`id`, `notification_noticequeuebatch`.`pickled_data` FROM `notification_noticequeuebatch`; args=()
(0.001) SELECT `auth_user`.`id`, `auth_user`.`username`, `auth_user`.`first_name`, `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`, `auth_user`.`is_active`, `auth_user`.`is_superuser`, `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user` WHERE `auth_user`.`id` = 3 ; args=(3,)
emitting notice new_msg to userTest
(0.000) SELECT `notification_noticetype`.`id`, `notification_noticetype`.`label`, `notification_noticetype`.`display`, `notification_noticetype`.`description`, `notification_noticetype`.`default` FROM `notification_noticetype` WHERE `notification_noticetype`.`label` = new_msg ; args=('new_msg',)
(0.000) SELECT `django_site`.`id`, `django_site`.`domain`, `django_site`.`name` FROM `django_site` WHERE `django_site`.`id` = 1 ; args=(1,)
(0.001) SELECT `cities_city`.`id`, `cities_city`.`name` FROM `cities_city`; args=()

还有许多与上面写的 notification.queue() 没有任何关系的其他额外的 sql 查询(如最后一个 - 从 city_city 中选择)。

emit_notices 调用 send_all() 和 send_all() 调用

send_now([to_user], label, extra_context, on_site, sender)

我没有看到与城市的关系,这是我项目的一个完全不同的应用程序。

但是它有效,但我想弄清楚为什么会发生这种情况。我做错了吗?

干杯

【问题讨论】:

    标签: python django


    【解决方案1】:

    我敢打赌,这些查询是由通知模板渲染生成的。

    【讨论】:

    • 我也想过。我从模板中删除了 {{ 所有带花括号的内容 }} ...仍然得到查询。如果这就是你的意思..
    • {% %} 呢?从模板中删除所有内容以确保。
    • 我删除了该死的东西,它仍然发送默认的..我从 site-packages/djang_notification 截断了默认的,额外的查询仍然被打印出来......我想我会去全新安装,看看效果如何
    • 你可以从 send_now() 调试
    • 我创建了一个新项目,对其进行了测试并在没有额外查询的情况下工作.. 我如何从 send_now() 进行调试?
    猜你喜欢
    • 1970-01-01
    • 2015-01-05
    • 2015-07-20
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 2017-10-11
    • 1970-01-01
    相关资源
    最近更新 更多