Django 预定作业

发布于 2024-08-07 22:30:43 字数 191 浏览 7 评论 0原文

我正在为一个由 Django 提供支持的网站编写一些拍卖功能,并且可以选择在每次有人出价时将拍卖延长几秒钟(这样就不会出现最后一刻的狙击)。拍卖结束后,需要完成某些事情,例如通知获胜者获胜并通知卖家他们需要将物品发送给谁。

在 Django 中,每当拍卖结束时,尤其是当拍卖结束时间可能是一个移动目标时,我如何运行拍卖完成脚本?

谢谢。

I'm writing some auction functionality for a website powered by Django, and there is an option to have the auction be extended by a few seconds every time somebody bids (so that there is no last-minute sniping). When the auction is finished, certain things need to be done like notifying the winner of their victory and notifying the seller to whom they need to send the item.

How, in Django, do I go about running an auction-completion script whenever an auction ends, especially when the auction end time may be a moving target?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不必在意 2024-08-14 22:30:43

听起来可以在 bid() 视图上轻松扩展拍卖结束日期时间字段

至于通过电子邮件发送结果,您应该编写一个管理脚本 http://docs.djangoproject.com/en/dev/howto/custom-management-commands/ 检查已结束和尚未结束的拍卖已发送通知并安排此脚本在 cron 中定期运行(如果需要,按分钟运行)。一个例子是 pinax 的 django-notification emit_notices 脚本。

http://github.com/jtauber/ django-notification/blob/master/notification/management/commands/emit_notices.py

更好的是,您可以利用 django-notification 本身。

It sounds like extending an auction_end DateTime field could easily be done on the bid() view

As far as emailing outcomes you should write a management script http://docs.djangoproject.com/en/dev/howto/custom-management-commands/ checking for auctions that have ended and haven't had notifications sent and schedule this script to run in cron at regular intervals (by minute if neccessary). An example would be pinax's django-notification emit_notices script.

http://github.com/jtauber/django-notification/blob/master/notification/management/commands/emit_notices.py

Better still you might be able to leverege django-notification itself.

忆离笙 2024-08-14 22:30:43

Django 命令扩展 提供作业系统 (作业调度)。将其添加到 crontab 后,它能够每小时/每天/每周/每月运行作业。

我认为扩展作业管理命令来完成您的任务应该很容易。

Django command extensions provides jobs system (job scheduling). After you add it to the crontab it is capable of running jobs hourly/daily/weekly/monthly.

I think that it should be easy to extend job management command to acomplish your tasks.

许仙没带伞 2024-08-14 22:30:43

听起来您可能希望让负责关闭拍卖的任何代码触发自定义信号以表明拍卖正在发生。

Sounds like you probably want to have whatever code is responsible for closing the auction fire a custom signal to indicate that it's happening.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文