# Schedule task in Django

**URL:** <https://forum.djangoproject.com/t/schedule-task-in-django/14095>\
**Category:** Deployment\
**Created:** [June 2, 2022, 10:23pm UTC](https://forum.djangoproject.com/t/schedule-task-in-django/14095 "2022-06-02T22:23:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smailt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/smailt/32/8270_2.png) [@smailt](https://forum.djangoproject.com/u/smailt)\
**Post date:** [June 2, 2022, 10:23pm UTC](https://forum.djangoproject.com/t/schedule-task-in-django/14095/1 "2022-06-02T22:23:13Z")

</div>

Hi everyone,  
I am trying to schedule a sending function in Django so in views.py I wrote this function  
but I have a problem that the application stop running and only did the SendingEmail function?

```auto
import schedule
import time
def SendingEmail():
    print('ok message')
schedule.every(5).minutes.do(SendingEmail)
while 1:
    schedule.run_pending()
    time.sleep(1)

```

is there a way to do this without affecting the application(easy and fast)?

All my best

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 2, 2022, 10:29pm UTC](https://forum.djangoproject.com/t/schedule-task-in-django/14095/2 "2022-06-02T22:29:19Z")

</div>

You need to set up an external task to do this.

You can either use something like Celery Beats or a Cron task to run a custom management command.

Either way, this sort of task is run external to the regular Django process.
