diff --git a/slides.md b/slides.md index 2a51809..7651d1d 100644 --- a/slides.md +++ b/slides.md @@ -1,5 +1,5 @@ --- -title: Empowering Django with Background Workers +title: Bringing Background Workers to Django class: text-center highlighter: shiki transition: slide-left @@ -9,11 +9,12 @@ themeConfig: primary: '#0c4b33' --- -# Empowering with Background Workers +# Bringing Background Workers to ## Jake Howard{.mt-5} -### Djangocon Europe 2024{.mt-5} +### Django London{.mt-5} +#### September 2024 @@ -332,7 +335,7 @@ layout: section @@ -609,6 +612,7 @@ layout: fact --- @@ -678,7 +682,9 @@ from wagtail.models import Page from django.tasks import task @task() -def send_email_to_user(page: Page, user: User): +def send_email_to_user(page_id: int, user_id: int): + page = Page.objects.get(id=page_id) + user = User.objects.get(id=user_id) email_content = render_to_string("notification-email.html", {"user": user, "page": page}) send_mail( subject=f"A change to {page.title} has been published", @@ -688,7 +694,7 @@ def send_email_to_user(page: Page, user: User): ) for user in page.subscribers.iterator(): - send_email_to_user.enqueue(user) + send_email_to_user.enqueue(user.id) ``` ```` @@ -714,48 +720,6 @@ for user in page.subscribers.iterator(): - With 0 lines changed --> ---- -layout: center ---- - - - -```python -# settings.py -EMAIL_BACKEND = "django.core.mail.backends.tasks.SMTPEmailBackend" -``` - - - -
- -```python -from django.contrib.auth.models import User -from django.core.mail import send_mail -from django.template.loader import render_to_string - -from wagtail.models import Page - -for user in page.subscribers.iterator(): - email_content = render_to_string("notification-email.html", {"user": user, "page": page}) - send_mail( - subject=f"A change to {page.title} has been published", - message=email_content - from_email=None, # Use the default sender email - recipient_list=[user.email] - ) -``` - - - --- layout: image-right image: /soon.png @@ -891,7 +855,7 @@ layout: section # Where are we now? --- @@ -916,19 +880,17 @@ layout: section --- @@ -939,6 +901,8 @@ layout: section --- @@ -1003,6 +969,8 @@ class: flex justify-center flex-col text-xl - Bringing the stability and longevity guarantees that come with Django - Doesn't mean they'll never come - With your help, we can make these happen + - Except swappable argument serialization + - `pickle` is a bad idea --> --- @@ -1047,7 +1015,7 @@ layout: section - Test it out - Report back your issues - Suggest improvements - - Issues / Discussions are open + - Issues / Discussions are open and active - If you want to get involved, please do! - There's plenty of work to do - And I can't do it alone!