Hi,

If you want to see something in the queryset you need to query it :)

For example:

 <a href="/posts/{{ question.id }}/">{% for question in
latest_question_list %} {{question.id }}{%endfor%}</a>

Or you can take the last or first item?
 <a href="/posts/{{ question.id }}/">{{ latest_question_list.first.id }}</a>

Regards,

Andréas


Den tors 7 maj 2020 kl 07:55 skrev Mohsen Pahlevanzadeh <
[email protected]>:

> I have the following view function:
> ################################
> def index(request, question_id):
>     latest_question_list = User.objects.all() #Post.objects.all()
>     template = loader.get_template('posts/index.html')
>      context = {
>            'latest_question_list': latest_question_list,
>        }
>      return HttpResponse(template.render(context))
> #########################################
> And the following template:
> ########################################
> {% if latest_question_list %}
>
>            salaam
>           <a href="/posts/{{ question.id }}/">{{ latest_question_list
> }}</a>
>  {% endif %}
> ###########################################
>
> I see the following result in my browser:
> #############################################
>
> salaam
> <QuerySet [<User: m_pahlevanzadeh>]>
>
>
> ##########################################
>
> How Can I some field in my Queryset in template?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJFFGZLhqwkvNVbHtGoU2zG5HdNjy-xbL7NbSTWJxfN0tnaZKQ%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCc%2BL-uALmAfrfGYKGUuyEHUK%2BAW7fgg6%2BOPWztbSL-pCg%40mail.gmail.com.

Reply via email to