View에서 template로 생일정보를 넘긴 후 template에서 나오게 하고 싶은데 정보가 넘어오지 않습니다.
조회수 438회
현재는 notice_board app이고 accounts app의 모델에서 생일 정보를 가져와 notice_board의 템플릿인 index_notice.html 에 나타내고 싶습니다. 근데 다른 정보들은 정상적으로 템플릿에 나타나는데 이 생일정보만 나타나지 않습니다. 어떤 문제가 있을까요?
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
email = models.EmailField(null=True)
full_name = models.CharField(max_length=50)
birthday = models.DateField()
def __str__(self):
return self.user.username
이건 account앱의 model
from accounts.models import UserProfile
def birthday_check(request):
birthday_list = UserProfile.objects.all()
return render(request, 'notice_board/index_notice.html', {'birthday_list': birthday_list})
notice_board앱의 view입니다.
<div class="birthday_box">
{% if birthday_list %}
<ul class="new_ul" style="padding: 10px 0; border-bottom: 1px black">
{% for birth_person in birthday_list %}
<li class="new_list" style="padding: 10px;">
{{ birth_person.birthday }}
</li>
{% endfor %}
</ul>
{% else %}
<p>오늘자 생일인 동아리 회원이 없습니다.</p>
{% endif %}
</div>
분명히 admin으로 birthday 데이터가 있는것도 확인하였는데도 아무런 정보가 템플릿으로 넘어가지 않아 {% else%}안에 있는 '오늘자 생일인 동아리 회원이... '만뜹니다... 어느부분이 잘못되었을까요?
댓글 입력