Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago. Improve this question I’m currently working on a project and my task is to build a feature for users to rate different countries
Tag: django-templates
Django 2.0 – Reverse for ‘password_change_done’ not found. ‘password_change_done’ is not a valid view function or pattern name
I’m having this error message after trying to change my app’s password. Do you have any idea of what’s causing this route to fail? Actually, it is changing the password but it isn’t rendering the success template “password_change_done.html”. Thanks! app/urls.py ERROR MESSAGE app/templates/registration/password_change_form.html app/templates/registration/password_change_done.html Thanks for your help! Answer I think the problem here is, as Tobit hints, is that
Generate PDF from html template and send via Email in Django
I’m trying to generate a pdf file from an HTML template using Weasyprint python package and I need to send it via email using. Here’s what i have tried: But it returns an error as TypeError: expected bytes-like object, not HttpResponse How can I generate and send a pdf file to an email from HTML template? Update: With this updated
NoReverseMatch with keyword argument uidb64 with Django 2.0
I can’t understand why my code doesn’t work. Before it worked, but now, when I run the server and test, the code does not work. When the user is registering, I send him activation email, like this: acc_active_email.html and my url file but I have this error: highlights this line http://{{ domain }}{% url ‘activate’ uidb64=uid token=token %} Answer In
Invalid Endblock tag in django
I am receiving an error message when I go to one of my pages in my Django project, as it is saying that the End-block tag is invalid (asks whether I remembered to register or load). The error looks like this: My code for this template – (login.html) – is below: I am very confused, and I am wondering whether
Django: Use firstof of if-else block inside blocktrans
I have two variables var1 and var2. I want to do this, It gives me error that ‘blocktrans’ doesn’t allow other block tags. Because we are not allowed to use any other tag inside blocktrans, what is the solution of this kind of problem? Answer From django 1.9 onwards, you can use firstof to assign result to context. See django-docs
Not able to use conditional tags in for loop in Django template file
I’m using Django 1.4/python 2.7.9 (because I’m required to, I know 1.4 is pretty old now) and I’m pretty green with django/python. In my template file, I seem to be unable to use any of the cool conditional tags like ifchanged or ifequal within a for loop. For example: This throws the error “Encountered unknown tag ‘ifchanged’. Jinja was looking
Django: How to apply conditional attribute to HTML element in template?
I have a checkbox in my Django jinja template. I want that checkbox to be checked if object boolean field is True. My html element looks like: The problem is, checkbox is still checked when attribute checked=”False”, it’s becomes unchecked only when the checked attribute is not there. So what i need is, put checked attribute into the html element
Building ‘limitless’ menu trees with Django
I have a model: And want to build a template which contains menu with limitless parent-child relations for each entry, where parent id’s of the “first-level” elements is 0. And as a result to build any html menu trees I want. Answer Don’t re-invent the wheel; use a dedicated Django extension for building tree-structures. There are several packages available that
What is the equivalent of “none” in django templates?
I want to see if a field/variable is none within a Django template. What is the correct syntax for that? This is what I currently have: In the example above, what would I use to replace “null”? Answer None, False and True all are available within template tags and filters. None, False, the empty string (”, “”, “”””””) and empty