-2
In my model I have an option list and when I display it in the template it appears like this: "("D", "Slow")" and I would like it to be displayed only "("Slow down")".
Currently
As it should be
Model.py
class Perfil(models.Model):
vel = (
("D", "Devagar",),
("N", "Normal"),
("R", "Rápido "),
("S", "Super Rapido (Cuidado!)"),
)
velocidade = models.CharField(max_length=1, choices=vel, null=True, blank=True, verbose_name='Velocidade')
py views.
from django.shortcuts import render
from .models import Perfil
def account(request):
user_id = request.user.id
perfil = Perfil.objects.get(usuario_id=user_id)
return render(request, 'core/account.html', {'nome': user_id, 'dados':perfil })
home html.
<select class="form-control select2 select2-hidden-accessible" style="width: 100%;" data-select2-id="1" tabindex="-1" aria-hidden="true">
{% for opcao in dados.vel %}
<option data-select2-id="{{opcao}}">{{ opcao }}</option>
{% endfor %}
</select>