dfunckt / django-rules

Awesome Django authorization, without the database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use rule in crontab

ajit2688 opened this issue · comments

Its not an Issue but need help in my use case

I want to execute sample rule in crontab using django-cron

corn.py

from django_cron import CronJobBase, Schedule
import rules

class MyCronJob(CronJobBase):
RUN_EVERY_MINS = 1 # every 2 hours

schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
code = 'my_app.my_cron_job'    # a unique code

def do(self):
    print(rules.test_rule('some_rule'))

rule.py

import rules

@rules.predicate
def some_rule():
print("HI")
return True

rules.add_rule('some_rule',some_rule)

instead of getting True I am getting False.

Closing since it's been a while and hopefully you have resolved the issue. It's not apparent to me what's the issue from the description. Closing, feel free to reopen if it's still an issue for you.