I have an unrealistic problem. In my django application, I use signals to send emails. All signals work, with the exception of one that runs from the django-admin command - django.core.management.base.NoArgsCommand (which runs through manage.py).
I checked my signal in different places, it works, except for this place.
Here is the code where I send the signal:
from django.core.management.base import NoArgsCommand
class Command(NoArgsCommand):
help = "Send email advertisement expiration reminder to users"
def handle_noargs(self, **options):
from app.models import Advertisement, User
from app.signals import ad_expires
from datetime import datetime
start=datetime(datetime.now().year, datetime.now().month, datetime.now().day+4,0,0)
end=datetime(datetime.now().year,datetime.now().month,datetime.now().day+4,23,59)
ads=Advertisement.objects.filter(visible_till__gte=start).filter(visible_till__lte=end)
for ad in ads:
ad_expires.send(self,ad=ad, user=ad.user)
print "Expiration reminders sent to %s users" % len(ads)
Am I doing something wrong?
Also, is there an easier way to check the date for one day?
Thanks for any advice.
source
share