Python Forum
Working on an Auction Site - had questions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working on an Auction Site - had questions
#20
So the main way, would be to actually use each field you want to display within the template:
{{% for query in queries %}
            <p>{{ query.title }} - {{ query.description }} - {{ query.price }} - {{ query.category }}<p>
{% endfor %}  
If you don't want to do that, you can try (I haven't actually tested this, I'm just guessing it'll work) using the __str__() method to describe what your object looks like as a string:
class NewPost(models.Model):
    title = models.CharField(max_length=64)
    description = models.CharField(max_length=64)
    price = models.IntegerField()
    category = models.CharField(max_length=64)

    def __str__(self):
        return f"{self.title} - {self.description} - {self.price} - {self.category}"
Reply


Messages In This Thread
RE: How to print the data from a Query Set with Django - by nilamo - Sep-09-2020, 02:27 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020