説明、題が伝わりずらかったら申し訳ございません
Win10 Python3.7.3
したい事
django のtemplate.html でmodels で設定した複数のmodelを出力できるようにしたい。
イメージとしては下記のように holiday11とholiday2 のデータをholidaylistで確認したいです。
何か方法はあるのでしょうか
models
1~~~~~~~~~~~~~~~~~~~略~~~~~~~~~~ 2class holiday1(models.Model): 3 holidayy1 = models.DateField() 4 5 def __str__(self): 6 return str(self.holidayy1) 7 def get_absolute_url(self): 8 return reverse('detail', kwargs={'pk':self.pk}) 9 10class holiday2(models.Model): 11 holidayy2 = models.DateField() 12 13 def __str__(self): 14 return str(self.holidayy2) 15 def get_absolute_url(self): 16 return reverse('detail', kwargs={'pk':self.pk}) 17
views
1from .models import holiday1 , holiday2 2~~~~~~~~~~~~~~~~~~~~~~~~~~~~略~~~~~~~~~~~~~~~ 3class holidaylist(ListView): 4 template_name = 'holidaylist.html' 5 model = holiday1 , holiday2
holidaylist
1{% block content %} 2<div class='container'></div> 3 <table class="table table-bordered table-dark"> 4 <thead> 5 <tr> 6 <th scope="col">holiday1</th> 7 <th scope="col">holiday2</th> 8 </tr> 9 </thead> 10 <tbody> 11 {% for item in object_list %} 12 <tr> 13 <td>{{ item.holidayy1 }} </td> 14 <td>{{ item.holidayy2 }} </td> 15 </tr> 16 {% endfor %} 17 </tbody> 18 </table> 19 20 </div> 21 22</div> 23{% endblock content %}
error
1AttributeError at /holidaylist 2'tuple' object has no attribute '_default_manager
追記
下記で解決するかもしれないです。
https://teratail.com/questions/108094
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。