django-wkhtmltopdf icon indicating copy to clipboard operation
django-wkhtmltopdf copied to clipboard

make_absolute_paths don't depend anymore on STATIC_URL

Open dvl opened this issue 8 years ago • 10 comments

Attempt to fix #103

dvl avatar Dec 08 '16 00:12 dvl

@dvl thanks for the contrib, can you make sure tests are passing before I start reviewing this? Thanks !

johnraz avatar Jan 28 '17 17:01 johnraz

@dvl friendly ping regarding this PR :-)

johnraz avatar Mar 05 '17 10:03 johnraz

@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?

dvl avatar Mar 26 '17 21:03 dvl

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!

axerdan avatar Jul 13 '17 11:07 axerdan

any chance those changes be merged? the tests failed because of a connection error.

fixmycode avatar Jul 17 '17 16:07 fixmycode

@fixmycode there are also conflict to resolve first.

johnraz avatar Jul 17 '17 17:07 johnraz

@johnraz can I fix them? should I make a new PR?

fixmycode avatar Jul 17 '17 17:07 fixmycode

Sure go with a new PR

johnraz avatar Jul 17 '17 19:07 johnraz

@dvl if you merge the new master (d31e839) tests should be working now

fixmycode avatar Jul 20 '17 21:07 fixmycode

I've updated the master but I'd like to implement @Keeper82 idea to deal with media files

dvl avatar Jul 20 '17 21:07 dvl