Question

I'm trying to do the following with django and celery. Here is a simplified version of what I'm doing

@task        
def dl_and_save_to_documents(document_pk):
        document = Document.objects.get(pk=document_pk)
        f = urlopen("some/url/etc/file.pdf")
        document.pdf_file=f
        document.save()

No errors are returned but pdf_file remains null. Any ideas?

Thanks!

Was it helpful?

Solution

You could use a different file retrieval method. I.e. urllib.urlretrieve().

OTHER TIPS

Try grab instead of urllib. It gives you nice wrapper around cURL lib, actually it's headless browser but currently w/o JS support.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top