update celery call
This commit is contained in:
parent
288abf1ad0
commit
3a48ac9c6b
@ -3,6 +3,10 @@ from django.db import models
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from . import utils
|
from . import utils
|
||||||
|
from . import tasks
|
||||||
|
from caromserver import celery
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
|
||||||
|
|
||||||
class LocationData(models.Model):
|
class LocationData(models.Model):
|
||||||
@ -86,4 +90,10 @@ class Accounting(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-time_from']
|
ordering = ['-time_from']
|
||||||
verbose_name = "Buchhaltungseintrag"
|
verbose_name = "Buchhaltungseintrag"
|
||||||
verbose_name_plural = "Buchhaltungseinträge"
|
verbose_name_plural = "Buchhaltungseinträge"
|
||||||
|
|
||||||
|
|
||||||
|
def update_location_data(sender, instance, **kwargs):
|
||||||
|
tasks.process_location_data.delay()
|
||||||
|
|
||||||
|
post_save.connect(update_location_data, sender=LocationData)
|
||||||
|
@ -4,5 +4,9 @@ from . import models
|
|||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def add(x, y):
|
def process_location_data():
|
||||||
return x + y
|
data = models.LocationData.objects.filter(processed=False)
|
||||||
|
print(len(data))
|
||||||
|
for ld in data:
|
||||||
|
print(ld)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
import os
|
import os
|
||||||
|
import django
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
@ -14,7 +15,11 @@ app = Celery('caromserver')
|
|||||||
app.config_from_object('django.conf:settings')
|
app.config_from_object('django.conf:settings')
|
||||||
|
|
||||||
# Load task modules from all registered Django app configs.
|
# Load task modules from all registered Django app configs.
|
||||||
#app.autodiscover_tasks()
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "caromserver.settings")
|
||||||
|
django.setup()
|
||||||
|
|
||||||
|
app.autodiscover_tasks(['billard'])
|
||||||
|
|
||||||
|
|
||||||
@app.task(bind=True)
|
@app.task(bind=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user