File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,38 @@ The default processor is `pictures.tasks.process_picture`. It takes a single
227227argument, the ` PictureFileFile ` instance. You can use this to override the
228228processor, should you need to do some custom processing.
229229
230+ ### Signals
231+
232+ The async image processing emits a signal when the task is complete.
233+ You can use that to store when the pictures have been processed,
234+ so that a placeholder could be rendered in the meantime.
235+
236+ ``` python
237+ # models.py
238+ from django.db import models
239+ from pictures.models import PictureField
240+
241+
242+ class Profile (models .Model ):
243+ title = models.CharField(max_length = 255 )
244+ picture = PictureField(upload_to = " avatars" )
245+ picture_processed = models.BooleanField(editable = False , null = True )
246+
247+
248+ # signals.py
249+ from django.dispatch import receiver
250+ from pictures import signals
251+
252+ from .models import Profile
253+
254+
255+ @receiver (signals.picture_processed, sender = Profile._meta.get_field(" picture" ))
256+ def picture_processed_handler (* , sender , file_name , ** __ ):
257+ sender.model.objects.filter(** {sender.name: file_name}).update(
258+ picture_processed = True
259+ )
260+ ```
261+
230262### Validators
231263
232264The library ships with validators to restrain image dimensions:
You can’t perform that action at this time.
0 commit comments