Reputation: 11
Not so long time ago I started programming on Django Framework.
I have a model Questions
with 2 attributes - question_text
and id
.
When my view works - in browser I see output smth like this:
[< Questions: First question >, < Questions: Second question >, < Questions:Third question >]
But I just want to see:
First question, Second question, Third question.
What should I do to fix it? Smth with __str__
function in model or what?
Upvotes: 0
Views: 31
Reputation: 3240
question = Questions.objects.all()
returns a queryset which you obviously print in your template. Try iterating over your queryset in your html template like:
{% for q in questions %}
{{ q.question_text }}{% if not forloop.last %}, {% endif %}
{% endfor %}
Hope this helps.
Upvotes: 1