Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how can i display the context data returned by the view in the template

Make sure the view contains the .Value() param
In Views.py
class LfrReportChapterOneView(PermissionRequiredMixin, TemplateView):
    template_name = "../templates/dashboards/lfr/lfr_report_chapitre1_create.html"

    def get_context_data(self, **kwargs):
        context = super(LfrReportChapterOneView, self).get_context_data(**kwargs)
        context["questions"] = ChapterQuestions.objects.filter(chapter_id=1).order_by("question_id").values()
        return context
      
In html file 
{% for qst in questions %}
      <tr>
      <td width="70%" style="font-weight: 400">{{ qst.question_wording }}:</td>
      <td><input type="text" placeholder="{{ qst.question_wording }}" class="test test2" required></td>
      </tr>
      {% endfor %}
Comment

PREVIOUS NEXT
Code Example
Python :: python tuple first column 
Python :: django url with special characters in template 
Python :: python vs python3 
Python :: datetime 
Python :: python slicing string 
Python :: To fix this error install pymongo with the srv extra 
Python :: como agregar una fila a un dataframe con pandas 
Python :: negative index python 
Python :: Basic Routing In Python 
Python :: How determine if a number is even or odd using bitwise operator 
Python :: normalize a distribution plot 
Python :: excel win32com select multiple cells in a row or column 
Python :: python too many values to unpack 
Python :: symmetric_difference_update() Function of sets in python 
Python :: python Write a program to reverse an array or string 
Python :: python Fibonacci series up to n 
Python :: immutabledict working 
Python :: python show difference between two strings and colorize it 
Python :: how to open cmd as administrator with python 
Python :: self argument in python 
Python :: how to install pygame for python 3.8.5 
Python :: mlpclassifier check weights 
Python :: python os module using stat 
Python :: Using CGI with Python and HTML forms 
Python :: problem 1 dot product python 
Python :: is : and :: the same in python slice 
Python :: python selenium disable JavaScript Detection 
Python :: split credit card number python 
Python :: Seaborn boxplots shifted incorrectly along x-axis 
Python :: using django celery 5.0 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =