From 948bdf82b5449a66da94fb7ea3472b8d266dcc95 Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Tue, 16 Aug 2022 20:22:25 +0200 Subject: [PATCH] Fixed a NoneType error when the callback is not defined in project settings. --- django_celery_results/settings.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/django_celery_results/settings.py b/django_celery_results/settings.py index 11cb524b..c41a2469 100644 --- a/django_celery_results/settings.py +++ b/django_celery_results/settings.py @@ -5,7 +5,6 @@ def get_callback_function(settings_name, default=None): """Return the callback function for the given settings name.""" - callback = getattr(settings, settings_name, None) if not callback: return default @@ -22,12 +21,11 @@ def get_callback_function(settings_name, default=None): def get_task_props_extension(request, task_props): - """Extend the task properties with custom properties to fill custom models.""" - - task_props_extension = extend_task_props_callback(request, task_props) or {} - if task_props_extension is None: + """Extend the task properties with custom props to fill custom models.""" + if not extend_task_props_callback: return {} + task_props_extension = extend_task_props_callback(request, task_props) or {} if not isinstance(task_props_extension, Mapping): raise ImproperlyConfigured( "CELERY_RESULTS_EXTEND_TASK_PROPS_CALLBACK must return a Mapping "