Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

290
Visualizações
How to display different Charfields into one sentence?

I'm doing a Django project that it is basically an ecommerce but for cars. My model is the following:

 class Userpost(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
    title = models.CharField(max_length = 500)
    Year = models.CharField(max_length = 4)
    Mileage = models.CharField(max_length = 8)
    Make = models.CharField(max_length = 50)
    Model = models.CharField(max_length = 50)
    Price = models.DecimalField(max_digits=15, decimal_places=2)
    email = models.EmailField()
    date_published = models.DateField(default = timezone.now)

and my template is the following:

{% extends 'store/main.html' %}
{% load static %}

{% block content %}

<div class="row">
    {% for car in cars %}
    <div class="col-lg-4">
        <img class="thumbnail" src="{% static 'images/placeholder.png' %}">
        <div class="box-element product">
            <h6><strong>{{car.title}}</strong></h6>
            <hr>

            <button  class="btn btn-outline-secondary add-btn">Add to Cart</button>
            <a class="btn btn-outline-success" href="#">View</a>
            <h4 style="display: inline-block; float: right"> 
            <strong>${{car.Price|floatformat:2}}</strong></h4>

        </div>
    </div>
    {% endfor %}
</div>
{% endblock content %}

I was wondering if there is a way that i could remove the title from my model and instead of displaying {{car.title}}, I would display something like {{car.Year + car.Make + car.Model}}

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can't use the concatenation like above in the templates. But you can use this instead,

<h6><strong>{{car.Year}} {{car.Make}} {{car.Model}}</strong></h6>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda