django-background-task not functioning all for me.

my django-background-task does nothing, even if I just ask it to do something simple like printing a string.
I dont know what I am doing wrong though.

from django.http import HttpResponse
from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
from .forms import UserRegistrationForm
from .models import Player, PlayerStats, TotalLevels
from django.core import management
from background_task import background
import random

# background task
def play_run():
    print('it works!')
    # management.call_command('runscript', 'runnerscript')

def random_logo():
    logo = random.randint(1, 5)
    logo_file = 'logo-nav'+str(logo)+'.png'
    return logo_file

# Main website views

def home(request):
    return render(request, template_name='main/home.html')

# bloxors website specific views

def homepage(request):
    logo_file = random_logo()
    return render(request, template_name='bloxors/homepage.html', context={'logo':logo_file})

# view in which background task is called
def play_redirect(request):
    return HttpResponse('Please wait while we redirect you...')

Can someone help me by telling what is going wrong?

As always, I appreciate any and all answers!

I’m afraid I’m not super familiar with the library in question - could you link to it so we have a chance to maybe see what’s wrong?

1 Like

I am also trying to have background-tasks running. Can’t figure how.
Have you found a solution?

1 Like

you need to run the tasks explicitly using a command in your terminal / command prompt. The command would be python process_tasks . For more info checkout the documentation: Django background tasks documentation

Yes thanks, it works!