How do I schedule a job in Django?
<p>I have to schedule a job using <a href="https://pypi.python.org/pypi/schedule" rel="nofollow">Schedule</a> on my <a href="https://www.djangoproject.com/" rel="nofollow">django</a> web application.</p>

<pre><code>def new_job(request): 
   print("I'm working...")   
   file=schedulesdb.objects.filter (user=request.user,f_name__icontains ="mp4").last()    
   file_initiated = str(f_name)  
   os.startfile(f_name_initiated)
</code></pre>

<p>I need to do it with filtered time in db</p>

<pre><code>GIVEN DATETIME = schedulesdb.objects.datetimes('request_time', 'second').last()
schedule.GIVEN DATETIME.do(job)
</code></pre>

<p>Django is a web framework. It receives a request, does whatever processing is necessary and sends out a response. It doesn't have any persistent process that could keep track of time and run scheduled tasks, so there is no good way to do it using just Django.</p>

<p>That said, Celery (<a href="http://www.celeryproject.org/" rel="nofollow">http://www.celeryproject.org/</a>) is a python framework specifically built to run tasks, both scheduled and on-demand. It also integrates with Django ORM with minimal configuration. I suggest you look into it.</p>

<p>You could, of course, write your own external script that would use schedule module that you mentioned. You would need to implement a way to write shedule objects into the database and then you could have your script read and execute them. Is your "scheduledb" model already implemented?</p>

python django