Fix celery task running
This commit is contained in:
@ -0,0 +1,5 @@
|
||||
# This will make sure the app is always imported when
|
||||
# Django starts so that shared_task will use this app.
|
||||
from .celery import app as celery_app
|
||||
|
||||
__all__ = ('celery_app',)
|
||||
|
||||
@ -179,7 +179,9 @@ class AudioScrobblerImportCreateView(
|
||||
@permission_classes([IsAuthenticated])
|
||||
@api_view(['GET'])
|
||||
def lastfm_import(request):
|
||||
lfm_import = LastFmImport.objects.create(user=request.user)
|
||||
lfm_import, created = LastFmImport.objects.get_or_create(
|
||||
user=request.user, processed_on__isnull=True
|
||||
)
|
||||
|
||||
process_lastfm_import.delay(lfm_import.id)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import os
|
||||
from celery import Celery
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "vrobbler.settings")
|
||||
app = Celery()
|
||||
app = Celery("vrobbler")
|
||||
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||
app.autodiscover_tasks()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user