I want django to automatically perform a certain task from time to time, this consists of creating an xml file, and sending it to a webservices so that it can be approved and return a response and store it. Well, I put together the data and I consume the service, but the problem is how I make this process automatic and from time to time.
buf = StringIO()
buf.write(documento_firmado)
buffer_xml = base64.encodestring(buf.getvalue())
# RECEPCION SRI TEST
client = Client(str(WS_RECEPCION))
result = client.service.validarComprobante(buffer_xml)
print result
if result.estado == 'RECIBIDA':
#grabar datos Autorizacion sri
retencion = Retencion.objects.filter(secuencia_id=secuencia).update(
clave_autorizacion = str(clave_acceso),
estado = 2
)
estado_recibido = 'ok_xml'
else:
estado_recibido = 'no_ok'
That would be the task that I want you to do from time to time, but since I don't know where to start, I appreciate any suggestion.
I am using a plugin called django-cron in my project .
Basically this plugin is based on creating a task and you can tell it to run every X minutes or at a specific time.
You can also force the execution of the crons from the manage so that it checks if it is being executed correctly.
Example
I leave the documentation here