Answer the question
In order to leave comments, you need to log in
How to populate a table from different database tables?
Hello! I need to populate a table with data from different postgresql tables. To fill the first column I wrote the code like this:
{%for i in word_kaz%}
<tr>
<td> {{i.words}} </td>
</tr>
{%endfor%}
{%for i in word_kaz%}
<tr>
<td> {{i.words}} </td>
<td> {{i.emotions}} </td>
<td> {{i.tr_rus}} </td>
<td> {{i.tr_eng}} </td>
</tr>
{%endfor%}
def dic_tonal(request, pk):
word_kaz = wordkaz.objects.all()
emo = emotion.objects.all()
rus_dic = rus.objects.all()
eng_dic = eng.objects.all()
return render(request, 'app/dic_tonal.html',{
'word_kaz': word_kaz,
'emo': emo,
'rus_dic': rus_dic,
'eng_dic': eng_dic,
})
class wordkaz(models.Model):
words = models.TextField()
class emotion(models.Model):
emotions = models.TextField()
class rus(models.Model):
tr_rus = models.TextField()
class eng(models.Model):
tr_eng = models.TextField()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question