There are some minor things that could be improved for beginners:
1) Looks like you forgot to import get_object_or_404
2) Would be nice if you would tell the reader where the code is meant to be located (view, urls, ...)
3) Is it possible to separate the CSS from HTML? {% static ... %} doesn't seem to work
I was just working on something similar. My two cents on the questions above.
2) Create a new file, such as pdf.py, and put all the code there. You can then either import it in your views.py or use directly as a view in urls.py (assuming you define a function that takes request as parameter).
3) It is possible to use static files by using a custom url_fetcher. Or just use django-weasyprint module, as that takes care of it for you.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you for this article!
There are some minor things that could be improved for beginners:
1) Looks like you forgot to import
get_object_or_404
2) Would be nice if you would tell the reader where the code is meant to be located (view, urls, ...)
3) Is it possible to separate the CSS from HTML?
{% static ... %}
doesn't seem to workGood catch! Thanks for the feedback. I’ll update the article sooner or later.
I was just working on something similar. My two cents on the questions above.
2) Create a new file, such as
pdf.py
, and put all the code there. You can then either import it in yourviews.py
or use directly as a view inurls.py
(assuming you define a function that takesrequest
as parameter).3) It is possible to use static files by using a custom
url_fetcher
. Or just usedjango-weasyprint
module, as that takes care of it for you.