django-wkhtmltopdf
django-wkhtmltopdf copied to clipboard
make_absolute_paths don't depend anymore on STATIC_URL
Attempt to fix #103
@dvl thanks for the contrib, can you make sure tests are passing before I start reviewing this? Thanks !
@dvl friendly ping regarding this PR :-)
@johnraz sorry for late response, I'm was not using wkhtmltopdf for a while.
I've updated tests for when templates use static files but I'm not sure on how to deal with media files because static finders don't search for uploaded files.
Any thoughts?
You can resolve MEDIA_URL url using a simple os.path.join.
https://github.com/incuna/django-wkhtmltopdf/pull/126/commits/9cdb5731017f24d119d8403c0b220f42412bd348#diff-36b0c981b229128ec810acc97c68d8feR247
This row should be something like this (not tested):
if occur.startswith(settings.STATIC_URL):
pathname = finders.find(filename, all=False)
else:
pathname = os.path.join(settings.MEDIA_ROOT, filename)
This patch could resolve a lot of problems with rendering templates using static/media urls!
any chance those changes be merged? the tests failed because of a connection error.
@fixmycode there are also conflict to resolve first.
@johnraz can I fix them? should I make a new PR?
Sure go with a new PR
@dvl if you merge the new master (d31e839) tests should be working now
I've updated the master but I'd like to implement @Keeper82 idea to deal with media files