Django Render HTML to PDF | Introduction

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 85

  • @DennisIvy
    @DennisIvy  3 หลายเดือนก่อน

    Don't forget to check out my Complete Django course! dub.sh/NvGboTI

  • @nehat786
    @nehat786 4 ปีที่แล้ว +7

    Love your tutorials! Easy and very well explained

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      Thank you! Glad you found them helpful :)

  • @jayshree9037
    @jayshree9037 4 ปีที่แล้ว

    I think you are the best django teacher

  • @nicko9958
    @nicko9958 11 หลายเดือนก่อน +2

    Is there a newer/better tool than xhtml2pdf, cause it seems like this tool doesn't support lots of css features and is only made for very simple html pages. But for me it doesn't work with elements that have posiotion absolute or even a clip-path. Do you know a tool, that supports all css?

  • @ammarrady7430
    @ammarrady7430 4 ปีที่แล้ว +3

    the problem is rendering images ( tried many different libraries but there is always an issue )

  • @ibrahimkilic85
    @ibrahimkilic85 4 ปีที่แล้ว +4

    First of all , Thanks. i have issue. i cannot view "ş, ğ, ı, İ etc." can you help me?

    • @zekict
      @zekict 2 ปีที่แล้ว

      Sorunu çözebildin mi? aynı dertten muzdaribim....

  • @sriram9786
    @sriram9786 3 ปีที่แล้ว

    Thanks exactly what I am looking for.

  • @nabinlama107
    @nabinlama107 4 ปีที่แล้ว +4

    brother thank you very much. I have a question that if i want to insert the data into invoice from database then how to code views function so that i can insert into invoice html file. could you please help me.

    • @tripathi5174
      @tripathi5174 4 ปีที่แล้ว

      Did you find any ways to do it sir???

    • @wethepeopleofghana8441
      @wethepeopleofghana8441 4 ปีที่แล้ว

      First query the database for the data you want, and then create a dictionary from it. The new dictionary will replace the static data dictionary that he has. Let me me know if you need help with that.

    • @alvarobencosme5348
      @alvarobencosme5348 4 ปีที่แล้ว

      @@wethepeopleofghana8441 i have a similar problem. I need a dynamic dictionary that depends the user selection. My problem is when going from one url[index] to another[function print], the variables change their value to None. you can help me pls?

    • @wethepeopleofghana8441
      @wethepeopleofghana8441 4 ปีที่แล้ว

      @@alvarobencosme5348 Yes, but I will have to see that part of your code. You can send me an email, aduemmanuelk21@gmail.com.

    • @wethepeopleofghana8441
      @wethepeopleofghana8441 4 ปีที่แล้ว

      @@alvarobencosme5348 I will be able to help, but I will have to see that part of your code. You can send me an email, aduemmanuelk21@gmail.com

  • @computinginfo3187
    @computinginfo3187 4 ปีที่แล้ว +2

    Dennis, may you please make a video on "csv files". Uploading and exporting them from a template with a table. Thanks!

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      It might be a bit before I get to that but I'll add it to my recommendations list. Thanks for the input :)

    • @sharifahmed1925
      @sharifahmed1925 4 ปีที่แล้ว

      Yes please!

  • @lucasowino4239
    @lucasowino4239 4 ปีที่แล้ว +1

    how do i write the data if its on my database.?

  • @rshnthms
    @rshnthms 3 ปีที่แล้ว +1

    Html won't use external css render to pdf?
    Any fix available?

    • @alekszmaalmen7559
      @alekszmaalmen7559 2 ปีที่แล้ว

      same issue, i provide a function for link_callback variable to perform the path of css file to an absolute path at my host machine, but css doesn't work.

  • @manishkumar710
    @manishkumar710 3 ปีที่แล้ว +1

    Hey dennis, actually i was working on an e-commerce website as a project. Then i came across the feature to render invoice to pdf and send it through e-mail. And your video helped alot. So Thank you💐. Also, i wanted your little help. Actually i am unable to print product(s) details on pdf, it says "you are passing more than 1 object" when there is more than 1 product. It's the "orderItem" model, and it is based on your e-commerce website video. Will you please help me with this?

  • @sergeiklimov2029
    @sergeiklimov2029 4 ปีที่แล้ว +1

    what should be on html template to render data in clean & in order

  • @mayankgupta6542
    @mayankgupta6542 3 ปีที่แล้ว +3

    How to display model object images in pdf?

    • @swiftstand
      @swiftstand ปีที่แล้ว

      You need to get the user image.path

  • @rdarktemplar1989
    @rdarktemplar1989 3 ปีที่แล้ว +1

    some syntax error, downloaded pdf has ' ' attached to it.

  • @pranathikodicherla3283
    @pranathikodicherla3283 3 ปีที่แล้ว

    The view button works perfectly for me but the download button is downloading a file of an unknown type. Thanks for the video :)

  • @souliphon_test3005
    @souliphon_test3005 4 ปีที่แล้ว

    I have a problem. I was following this but this cannot display another language like Thai or Lao.

  • @jaelmaciel3899
    @jaelmaciel3899 4 ปีที่แล้ว

    Thank you for sharing your knowledge! It was very useful for me.

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      Glad the video helped! Thanks for your feedback :)

  • @xlsautomatizaciones9197
    @xlsautomatizaciones9197 3 ปีที่แล้ว +1

    That works OK!! Thanks Dennis. I cant figure out how to attach the generated pdf to an email in order to send it . Anyone dealt with this? I would appreciate any help on this!

  • @sergeiklimov2029
    @sergeiklimov2029 4 ปีที่แล้ว +1

    Can you please advise what I should do to render cyrillic (russian) font on pdf page?

    • @ches_ter6842
      @ches_ter6842 3 ปีที่แล้ว

      Сергей, добрый день! Получилось ли решить вопрос с поддержкой кириллицы?

  • @hamzagt5
    @hamzagt5 3 ปีที่แล้ว +1

    Heyyy, really awesome tutorials, definitely worth the effort, I was wondering if you can do pdf download onto the Django CRM tutorial, that would help alot!!! 😀

  • @valdinia-office2910
    @valdinia-office2910 ปีที่แล้ว

    Excellent video, thank you so much Dennis!
    What about the diacritics? When the HTML contains letters like ă,î,ș,ț,â I get this error:
    UnicodeEncodeError
    'latin-1' codec can't encode characters in position 405-409: ordinal not in range(256)

  • @7even77
    @7even77 3 ปีที่แล้ว

    What if we use pagination, is it real to print all the pages on pdf?

  • @abdelmfossa
    @abdelmfossa 4 ปีที่แล้ว

    Thank you Sir. It's work.

  • @ayeshamunshi8043
    @ayeshamunshi8043 3 ปีที่แล้ว

    Excellent work !!! Need one help.


    test
    Logo File is not able to see in the pdf, created a issue in git

    • @zekict
      @zekict 2 ปีที่แล้ว

      Did you find a solution? Actually, there are no problems with images when working on Windos, when I set up the project to run on Ubuntu, there is no image in the pdf file, although images appear on other pages.

    • @ayeshamunshi8043
      @ayeshamunshi8043 2 ปีที่แล้ว

      @@zekict not so far

  • @alekszmaalmen7559
    @alekszmaalmen7559 2 ปีที่แล้ว

    Thanks for overview! My actual css styles doesn't work despite i provide a function for 'link_callback' variable to define the path of css file which used in my template. Also i check this path and it's correct. But css styles doesn't work.

  • @calebjebadurai
    @calebjebadurai 3 ปีที่แล้ว +1

    I want to create a multipage pdf with paragraph and table content. And the table may expand in rows thus making it multiple pages or a single page. I while doing this i also want to preserve the Header and Footer (both images). And I also want the liberty to be able to change the paper size. Default paper size = A4.
    Django + React

    • @samichosen524
      @samichosen524 ปีที่แล้ว

      I'm looking to do that also, did u got any solution for that?

  • @fastc0de931
    @fastc0de931 2 ปีที่แล้ว

    Hi, how can you render an image in the pdf?

  • @hamzagt5
    @hamzagt5 3 ปีที่แล้ว

    Do you have course in udemy or anywhere?? I’d for sure attend ! And please could you render to pdf on the asset management app crush course, it will help a ton!!! I really hope you see this comment 🥺

  • @prakashandsons
    @prakashandsons 3 ปีที่แล้ว

    is there something like html2image or render_to_image, i want to render template to a image file and send via telegram api

  • @schoolive7977
    @schoolive7977 4 ปีที่แล้ว

    Getting "unknown encoding: ISO-8859-1". PLZ HELP

  • @shyamkariya9818
    @shyamkariya9818 4 ปีที่แล้ว +1

    I want to save thi pdf in database how to do this

  • @dingli219
    @dingli219 4 ปีที่แล้ว

    Can you please add requirements.txt to your django projects?

  • @a.almakldi
    @a.almakldi 4 ปีที่แล้ว

    Need help please ... I did the same but unfortunately for it's printing scramble characters for Arabic characters ... Any one can help how to write Arabic characters to pdf.

  • @tripathi5174
    @tripathi5174 4 ปีที่แล้ว

    i am getting this error
    ModuleNotFoundError: No module named 'xhtml2pdf'
    even after installing

    • @amcpoland651
      @amcpoland651 4 ปีที่แล้ว +1

      not sure if its the issue but have you added it to your settings file?

  • @kaustubhgoyal4294
    @kaustubhgoyal4294 4 ปีที่แล้ว

    Please share the HTML template for the pdf as well

  • @balabalaji6259
    @balabalaji6259 4 ปีที่แล้ว

    Hi Bro. Awesome tutorials.! Could you please help to confirm is there way to open PDF file from desktop and extract specified field for 'n' number of PDF files in the folder via Django. I am trying to develop web app which can do PDF automation.

  • @СтаниславСтепанов-с1х
    @СтаниславСтепанов-с1х 4 ปีที่แล้ว +2

    Спасибо. Есть ли возможность увидеть это на русском?

    • @what-the-code
      @what-the-code 2 ปีที่แล้ว

      Have u got solution? Plz share

  • @walidnewaz6475
    @walidnewaz6475 4 ปีที่แล้ว

    Boss, how can i generate date wise sales report ?

  • @chetanrokade5156
    @chetanrokade5156 4 ปีที่แล้ว

    @Dennis, I am getting below error while calling render_to_pdf function : Please help
    Request Method: GET
    Request URL: 127.0.0.1:8000/pdf_view/
    Django Version: 2.1
    Exception Type: gaierror
    Exception Value:
    [Errno 11001] getaddrinfo failed

    • @chetanrokade5156
      @chetanrokade5156 4 ปีที่แล้ว

      class ViewPDF(View):
      def get(self, request, *args, **kwargs):
      keypoints = KeyPoints.objects.exclude(KP_Flag='False')
      tick_list = Tickets.objects.exclude(Tick_Flag='False')
      monthlyActs = Monthly.objects.all().order_by('Remark')
      out_list = Outages.objects.exclude(Outage_Flag='False')
      # cr_list = CR.objects.all().order_by('CR_StartTime')
      cr_list = CR.objects.exclude(CR_Flag='False').order_by('CR_StartTime')
      context = {
      'tick_list': tick_list,
      'keypoints': keypoints,
      'monthlyActs': monthlyActs,
      'out_list': out_list,
      'cr_list': cr_list,
      }
      pdf = render_to_pdf(
      'Consolidated/consolidated.html', context)
      return HttpResponse(pdf, content_type='application/pdf')
      and in consolidated.html I m printing values as below for each dictionary :
      {% for KP in context.keypoints %}

      {{ KP.KP_Added_On }}
      {{ KP.Added_By }}
      {{ KP.KP_Description }}


      {% endfor %}

  • @techtips9512
    @techtips9512 4 ปีที่แล้ว

    Hi thanks a nice video it helped me a lot.
    I want to get the template with its bootstrap designing but with this code its not working.
    another issue is the static images which are not loading.
    waiting for Response.

    • @safiullahkhansherzad7214
      @safiullahkhansherzad7214 4 ปีที่แล้ว

      for images. first of all you need to install pillow. secondly you need to do some setting inside the urls.py file which you can easily find on stackoverflow. just type static images not loading in django.

  • @nabil.hamawi
    @nabil.hamawi 4 ปีที่แล้ว

    it's not working in any other language!!

  • @saliksheraz6236
    @saliksheraz6236 4 ปีที่แล้ว

    Thanks Alot Brother

  • @paristar3079
    @paristar3079 4 ปีที่แล้ว

    It is not able to render Js charts

    • @indrasuyut1958
      @indrasuyut1958 3 ปีที่แล้ว

      You can use var jp64 to download image (chart)

  • @diescatric4559
    @diescatric4559 2 ปีที่แล้ว

    does not support other languages I got something like Date: ■■■■■■ ■■■■
    Amount: ■■■■■■■ ■■■
    Bill to: ■■■■■■■ ■■■■■■■ ■■■ ■■■ any help please

    • @what-the-code
      @what-the-code 2 ปีที่แล้ว

      Have u got solution? Plz share

  • @enrolmentaccount8713
    @enrolmentaccount8713 3 ปีที่แล้ว

    Hi Dennis - great video, thanks for doing it. I tried using this code within an admin action to create pdfs 'with selected items..' but I can only download a pdf for the last item in the action's queryset. Have you any plans, or would you be interested, in doing a video for creating and downloading pdfs from an admin action?

  • @copy4ever
    @copy4ever 4 ปีที่แล้ว

    Thank you for sharing

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว

      My pleasure :)

  • @AhmedTheCoder
    @AhmedTheCoder 4 ปีที่แล้ว

    I have problems with Arabic fonts

    • @what-the-code
      @what-the-code 2 ปีที่แล้ว +1

      Have u got solution? Plz share

  • @talgatv
    @talgatv 3 ปีที่แล้ว

    Спасибо бро

  • @issamohammed3529
    @issamohammed3529 4 ปีที่แล้ว

    how to show Arabic text ti pdf

    • @nabil.hamawi
      @nabil.hamawi 4 ปีที่แล้ว

      did you find the solution?

    • @what-the-code
      @what-the-code 2 ปีที่แล้ว

      Have u got solution? Plz share

  • @alphamusicbar
    @alphamusicbar 4 ปีที่แล้ว

    perfect

  • @Name-pn5rf
    @Name-pn5rf 4 ปีที่แล้ว

    pdf is corrupted

  • @komuisam6549
    @komuisam6549 3 ปีที่แล้ว

    men por que hacen esto así mucho código engorroso toca ir a buscar una manera mejor mas corta importan de todos lados y algunas cosas no las muestras

  • @hamisomary539
    @hamisomary539 ปีที่แล้ว

    i'm lovely fun of you bro you

  • @iamavichayil
    @iamavichayil 2 ปีที่แล้ว

    Did you every actually make the HTML to PDF video u mentioned at the end??