开发者

How can i enter some data after some regular interval in Django Model

I have Model

class Account:

and other model called

class Transactions:

Now i have field interest_rate in Account Model.

I want to pay the interest o开发者_高级运维n 3 month basis from the opening date of account. So i want the automatic transaction of the required amount applied to the account after every 3 months or depending upon the months specified

How can I achieve that


You could use cron or celery for starters.

Run a crontab every 3 months: https://serverfault.com/questions/129633/how-to-run-cron-job-every-3-months-in-apache2


A regular job would definitely work, but I don't think doing it every three months is the right approach. Instead, do it every day and query to find out which accounts need processing. Doing it this way, you can use various criteria to decide which accounts to process (you hinted you might need this in the question).

I would set up a standalone python script that had access to Django's models, using these techniques.

I would set up the script to run once per day. Each time it ran, it would do something like:

accounts = Account.objects.filter(date_added=<three months ago>).all()
for account in accounts:
    # do what needs to be done
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜