templates

Django views.py Exception Value: Could not parse the remainder:

Django views.py Exception Value: Could not parse the remainder: Question: I get an Exception Value error: Could not parse the remainder: ‘(column)’ from ‘item.get(column)’ views.py: def home(request): position = DjangoEmail.objects.get(Email=request.user).Position year_filter = Q(Year=now.year) | Q(Year=now.year-1) | Q(Year=now.year+1) if position == 7: data = Employee.objects.filter(year_filter, Mlkk=request.user).order_by(‘Year’,’OblastTM’).values(‘Year’, ‘OblastTM’, ‘Category’, ‘ProductGroup’,’NameChaine’).annotate(Januaru=Sum(‘January’)) elif position == 6: data = Employee.objects.filter(year_filter, …

Total answers: 1

build new variables in Jinja2 Loop and use it

build new variables in Jinja2 Loop and use it Question: I have a file containing a YAML document, with informations about vlans: #yaml_file.yaml – vlan: 123 name: DATEN-VLAN – vlan: 124 name: PRINTER-VLAN – vlan: 125 name: WLAN-VLAN Then I created a Jinja2Template to loop through the vlans: {% for vlan in vlans %} interface …

Total answers: 1

User input in HTML form not captured in Python correctly

User input in HTML form not captured in Python correctly Question: i have this html form where user can choose name from a list : {% block main %} <form action="/ballot" method="post"> 1st Choice <select name="name1"> <option disabled selected value="">name</option> {% for candidate in candidates %} <option value={{ candidate }}>{{ candidate["name"] }}</option> {% endfor %} …

Total answers: 1

How to send email in fastapi with template

How to send email in fastapi with template Question: conf = ConnectionConfig( USERNAME=config.mail_username, PASSWORD=config.mail_pasword, FROM=config.mail_from, PORT=config.mail_port, SERVER=config.mail_server, USE_CREDENTIALS=True, VALIDATE_CERTS=True, TEMPLATE_FOLDER=’./templates’ ) async def send_email(email_to: EmailSchema, body:EmailSchema) -> JSONResponse: message = MessageSchema( subject="fastapi", recipients=[email_to], body=body, subtype="html" ) fm = FastMail(conf) await fm.send_message(message,template_name=’email.html’) data="xyz" @app.get("/email") async def endpoint_send_email( ): await send_email( email_to=email_to, body=data ) email.html <!DOCTYPE html> …

Total answers: 2

Iterate over json string items in jinja2

Iterate over json string items in jinja2 Question: Hi I need to send data in string format to my jinja templates, and the render them. The only way I found is to format my data as JSON and send it as a string to the renderer. But I donĀ“t know how to use it in …

Total answers: 1

django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 13: 'endblock'. Did you forget to register or load this tag?

django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 13: 'endblock'. Did you forget to register or load this tag? Question: I’m trying to create a user registration in Django, but I have an issue with the template: registrazione.html. My github repo: https://github.com/Pif50/MobFix registrazione.html {% extends ‘base.html’ %} {% load crispy_forms_tags %} {% block head_title %} {{ block.super …

Total answers: 2

Python, create a kind of template for functions

Python, create a kind of template for functions Question: I have a class with three functions that do almost the same things but on different objects. And I think there is a better way to program it since it is a duplication of code, but I cannot see how to have a kind of template. …

Total answers: 2