Closed maxed0ut closed 6 years ago
Hi @maxed0ut, Silver has some tasks, including the PDF generation, that are best run asynchronously. Read https://github.com/silverapp/silver#automated-tasks for some info on how you can set them up.
Hi @bogdanpetrea Thanks for taking a look at this. Yes, I agree, these sorts of tasks are best automated. I looked at the link and saw that it also expects to save the data to S3.... 'For specifying the storage used add the SILVER_DOCUMENT_STORAGE setting to your settings file. Example for storing the PDFs on S3: SILVER_DOCUMENT_STORAGE = ( 'storages.backends.s3boto.S3BotoStorage', [], { 'bucket': 'THE-AWS-BUCKET', 'access_key': 'YOUR-AWS-ACCESS-KEY', 'secret_key': 'YOUR-AWS-SECRET-KEY', 'acl': 'private', 'calling_format': 'boto.s3.connection.OrdinaryCallingFormat' } )' I was using the browser method simply to allow a user to preview an invoice to check if it is appearing correctly.
Is there a way to use local file storage for either or both as I don't have S3?
Thanks in advance!
So you're saying that you ran the PDF generation task and you still have no PDF? I'm asking because unless you run silver.tasks.generate_pdfs
, you won't have a PDF after creating a Billing Document.
For a quick generation you should be able to run python manage.py generate_pdfs
.
AFAIK if you don't use the SILVER_DOCUMENT_STORAGE
setting, local storage will be used by default. The directory where the PDFs will be stored in this case corresponds to the MEDIA_ROOT
setting.
Hi Bogdan, thanks, you were right about the SILVER_DOCUMENT_STORAGE setting - when I removed it the generation worked! (Using python manage.py generate_pdfs)
I still get an error using the browser to find the file, but I get a sensible URL: http://127.0.0.1:8000/app_media/documents/myprovider/invoice/2018/09/21/Invoice_BILL-1.pdf
I have used the settings from @allox in issue 527....
MEDIA_ROOT = PROJECT_ROOT + '/app_media/' MEDIA_URL = '/app_media/'
I put os.getcwd() in settings.py and it returns: C:\Source\DJango_Tests\silverapp
MEDIA_ROOT is C:\Source\DJango_Tests\silverapp\silverapp\app_media/ MEDIA_URL is /app_media/
The PDF was generated in C:\Source\DJango_Tests\silverapp\silverapp\app_media\documents\myprovider\invoice\2018\09\21
My directory structure is: Project: C:\Source\DJango_Tests\silverapp contains the db, manage.py and the app folder
App folder in Project folder: C:\Source\DJango_Tests\silverapp\silverapp\
Documents were generated in C:\Source\DJango_Tests\silverapp\silverapp\app_media\documents\myprovider\invoice\2018\09\21
But I still don't get a PDF when clicking the link on the invoices screen... http://127.0.0.1:8000/app_media/documents/myprovider/invoice/2018/09/21/Invoice_BILL-1.pdf ==> 404
I'm running Windows 10. (Sorry about that!)
According to this stackoverflow answer you need to add
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT)
to your urls.py
file.
And you also need to have DEBUG = True
in your settings file, since this only works in debug mode.
Hi Bogdan, Yes, that really helped. I also had to change the ROOT_URLCONF = 'silver.urls' line as that was causing my urls.py project file to be ignored. I've closed the case, Thanks for the help!
Hi, I have installed Silver into an empty app and got it running using the settings suggested by @allox in issue 527.
I mark an invoice for generation OK, but when I try to download it I get an error and no PDF...
MissingSchema at /admin/silver/invoice/ Invalid URL 'None'
I believe the issues relates to SILVER_DOCUMENT_STORAGE = None
The only other examples I can find for this are for S3, but I don't have S3.
I noticed that in issue 114 (in 2015) https://github.com/silverapp/silver/issues/114 the 'hard' dependency on S3 was removed, but I can't seem to work out how.
Is this an issue or can you let me, and the rest of the non-S3 world, know how to switch to the local file storage system please? I would simply like to generate a PDF for a user to view/download in the browser
Your help is much appreciated.