diff --git a/public/celery.svg b/public/celery.svg
new file mode 100644
index 0000000..82900b1
--- /dev/null
+++ b/public/celery.svg
@@ -0,0 +1,29 @@
+
+
+
diff --git a/slides.md b/slides.md
index 819876c..07d8532 100644
--- a/slides.md
+++ b/slides.md
@@ -40,8 +40,7 @@ addons:
layout: center
---
-# Django isn't _just_ for websites
-
+# Django is a web framework
```mermaid
flowchart LR
@@ -54,9 +53,7 @@ flowchart LR
@@ -64,52 +61,66 @@ flowchart LR
layout: full
---
+# Django isn't _just_ for websites
+
```mermaid
-flowchart BT
+flowchart TD
U[User π§βπ»]
D[\Django/]
DB[(Database)]
- C[(Cache)]
E>Email]
EA[External API]
- V[[Video Transcode]]
- ML((Machine Learning))
+ V[[Video Transcoding]]
+ R[Reporting]
+ ML((Machine
Learning))
- U---->|Request|D
- D---->|Response|U
+ U<--->D
- D-.-DB & E & EA & V & ML & C
+ D---DB
+ D-..-E & EA & V & R & ML
```
+
+
+
---
layout: full
---
+# Background Workers!
+
```mermaid
-flowchart BT
+flowchart TD
U[User π§βπ»]
D[\Django/]
- DB[(Database)]
- C[(Cache)]
+
E>Email]
EA[External API]
- V[[Video Transcode]]
- ML((Machine Learning))
- B{{Background Processing}}
+ V[[Video Transcoding]]
+ R[Reporting]
+ ML((Machine
Learning))
- U--->|Request|D
- D--->|Response|U
+ B{{Background Processing}}
- D---B
+ U<-->D
- D-.-C & DB
+ D-..-B
- B---E & V & ML & EA
- B---C & DB
+ B---E & EA & V & R & ML
```
+
+
---
-layout: cover
+layout: section
---
# Background Workers?
@@ -126,11 +137,11 @@ flowchart LR
R2{Runner}
R3{Runner}
- D<--->S<-..->R1 & R2 & R3
+ D<----->S<-....->R1 & R2 & R3
```
---
-layout: cover
+layout: section
---
# When?
@@ -139,8 +150,6 @@ layout: cover
layout: fact
---
-
-
```mermaid
flowchart BT
D[\Django/]
@@ -163,14 +172,14 @@ flowchart BT
```
---
-layout: cover
+layout: section
---
# Background Workers _in Django_
---
layout: cover
-background: https://docs.celeryq.dev/en/stable/_static/celery_512.png
+background: /celery.svg
---
# Celery!
@@ -178,6 +187,7 @@ background: https://docs.celeryq.dev/en/stable/_static/celery_512.png
@@ -216,6 +226,29 @@ background: https://images.unsplash.com/photo-1522096823084-2d1aa8411c13?q=80&w=
layout: center
---
+# Sending an email
+
+```python {all|7|8|9-14|all}
+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: center
+---
+
```python {all|18|19|10|11-16|all|18-19|all}
from django.contrib.auth.models import User
from django.core.mail import send_mail
@@ -228,7 +261,7 @@ from wagtail.models import Page
def send_email_to_user(page: Page, user: User):
email_content = render_to_string("notification-email.html", {"user": user, "page": page})
send_mail(
- subject="A page has been published",
+ 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]
@@ -242,7 +275,7 @@ for user in page.subscribers.iterator():
layout: center
---
-# A problem
+# Using RQRQ Celery
````md magic-move
```python
@@ -257,7 +290,7 @@ from wagtail.models import Page
def send_email_to_user(page: Page, user: User):
email_content = render_to_string("notification-email.html", {"user": user, "page": page})
send_mail(
- subject="A page has been published",
+ 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]
@@ -280,7 +313,7 @@ from my_celery_config import app
def send_email_to_user(page: Page, user: User):
email_content = render_to_string("notification-email.html", {"user": user, "page": page})
send_mail(
- subject="A page has been published",
+ 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]
@@ -291,6 +324,12 @@ for user in page.subscribers.iterator():
```
````
+
+
---
layout: image
image: /situation.png
@@ -311,7 +350,7 @@ layout: fact
# `django.tasks`
-
django.tasks
+
````md magic-move
```python
from django.contrib.auth.models import User
@@ -352,7 +393,7 @@ from my_celery_config import app
def send_email_to_user(page: Page, user: User):
email_content = render_to_string("notification-email.html", {"user": user, "page": page})
send_mail(
- subject="A page has been published",
+ 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]
@@ -375,7 +416,7 @@ from django.tasks import task
def send_email_to_user(page: Page, user: User):
email_content = render_to_string("notification-email.html", {"user": user, "page": page})
send_mail(
- subject="A page has been published",
+ 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]
@@ -386,6 +427,12 @@ for user in page.subscribers.iterator():
```
````
+
+
---
layout: center
---
@@ -395,11 +442,12 @@ from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.template.loader import render_to_string
-email_content = render_to_string("email-template.html", {"page": page})
+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="The page has changed",
+ 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]
@@ -417,7 +465,6 @@ EMAIL_BACKEND = "django.core.mail.backends.tasks.SMTPEmailBackend"
-
---
layout: image-right
image: /soon.png
@@ -426,34 +473,31 @@ class: flex justify-center text-2xl flex-col
# Q: Why something new?
-