2014-01-22 56 views
0

我有一個問題。Django不顯示文本輸出

那麼, 當我去頁面'contact_list.html'我看不到文字輸出,我只看到子彈點,但沒有文字。

所以,我在這裏爲我的文件:

contact_list.html

<h1>Contacts</h1> 

<ul> 
    {% for cantact in object_list %} 
     <li class="contact">{{ contact.first_name }}</li> 
    {% endfor %} 
</ul> 

models.py:

from django.db import models 

class Contact(models.Model): 
    first_name = models.CharField(max_length=255) 
    last_name = models.CharField(max_length=255) 
    email = models.EmailField() 

    def __str__(self): 
     return self.first_name 

views.py:

from django.views.generic import ListView 

from contacts.models import Contact 


class ListContactView(ListView): 

    model = Contact 
    template_name = 'contact_list.html' 

所以,也許你知道這裏有什麼問題嗎? 謝謝;)

+0

在{%for object_list%中的cantact}中有一個聯繫錯誤' – arocks

回答

1

你在contact_list.html的for循環中寫了「cantact」而不是「contact」。