These are chat archives for django/django

30th
Oct 2017
Aaron Layfield
@DandyDeveloper
Oct 30 2017 09:06 UTC

Quick one everyone: What's the best way to have Django call a third party API in intervals without someone having to access an App/URL?

I.E. Poll this API source every minute. I've currently got it running as a service that is called everytime certain URLs visited

Aleksey Radchenko
@dixon-che
Oct 30 2017 09:15 UTC
Manage command on Cron. Or celery periodic task
Aaron Layfield
@DandyDeveloper
Oct 30 2017 09:20 UTC
I actually found a lightweight schedule package as celery was too overkill for the project. Thank you though!
Aaron Layfield
@DandyDeveloper
Oct 30 2017 14:45 UTC
I've decided to take the Celery route. Anyone got 5 minutes to explain calling external tasks to the Celery scheduler?
Aaron Layfield
@DandyDeveloper
Oct 30 2017 14:53 UTC

For when someone gets time: I've defined my tasks under my app/tasks.pyand registered them with the @shared_task. The Celery worker has picked them up and I can see this in the log.

How do I then use sender.add_periodic_task to call the specific task? I can't seem to get it working.

cs89gr
@cs89gr
Oct 30 2017 14:54 UTC
celery 4.1 work with windows or not ?
Aaron Layfield
@DandyDeveloper
Oct 30 2017 14:55 UTC
Celery 4.1 with Linux
I can see the task loaded in the worker:
[tasks]
  . articles.tasks.get_articles
  . articles.tasks.get_sources
  . celery.debug_task
cs89gr
@cs89gr
Oct 30 2017 14:56 UTC
fuck that is my wrong ?what version i need ?any idea ?
Aaron Layfield
@DandyDeveloper
Oct 30 2017 14:57 UTC
@cs89gr Yes, 4.1 should work with Windows.
cs89gr
@cs89gr
Oct 30 2017 14:59 UTC
work or not 4.1 with windows ?
Aaron Layfield
@DandyDeveloper
Oct 30 2017 15:02 UTC
OH my bad, I had no idea they stopped supporting Windows. @cs89gr No. It does not work as of version 4.X
cs89gr
@cs89gr
Oct 30 2017 15:03 UTC
its ok,you work with windows
?
Aaron Layfield
@DandyDeveloper
Oct 30 2017 15:06 UTC
I work with Linux.
cs89gr
@cs89gr
Oct 30 2017 15:08 UTC
nice
@DandyDeveloper what is the differend from @shared_task and app.task ?
klaxmi361
@klaxmi361
Oct 30 2017 18:29 UTC
how do i access a dict from template
kindly let me know
klaxmi361
@klaxmi361
Oct 30 2017 20:05 UTC
kindly help me on this
David Magerl
@dtm5011_twitter
Oct 30 2017 22:35 UTC
Hi. I'm trying to find a way to unit test an error code using a django formset. https://docs.djangoproject.com/en/1.11/topics/forms/formsets/#formset-validation I'm raising an error on the form with add error self.add_error( 'name', forms.ValidationError( "The name is required", code=self.NAME_REQUIRED ) ) In my unit test formset.errors returns {'name': ['The name is required']} Is there a way to get at the error code I'm setting in the ValidationError?