数据不';t出现在Django的html页面中

数据不';t出现在Django的html页面中,django,django-models,django-views,django-templates,Django,Django Models,Django Views,Django Templates,我的数据有问题,它没有出现在我的html页面中。我尝试过这样做,但什么也没有发生 model.py: class BestArticals(models.Model): name = models.CharField(max_length=240) url = models.URLField(default="",max_length=240) image = models.ImageField(upload_to='images/',null=Tru

我的数据有问题,它没有出现在我的html页面中。我尝试过这样做,但什么也没有发生

model.py:

class BestArticals(models.Model):
    name = models.CharField(max_length=240)
    url = models.URLField(default="",max_length=240)
    image = models.ImageField(upload_to='images/',null=True, blank=True)

    def get_image(self):
        if self.image and hasattr(self.image, 'url'):
            return self.image.url
        else:
            return '/path/to/default/image'

    def __str__(self):
        return self.name
veiws.py:

def Best_Articals(request):
    best_posts = BestArticals.objects.all()
    context = {'best_posts' : best_posts}
    return render(request,'android/side_bar_good_posts.html',context=context)
html页面:

{% for post in best_posts %}
<ul style="text-align:right">
  <li> <img src="{{post.get_image}}" height="80px" width="80px"> <a href="{{post.url}}" style="color:black"> {{post.name}}  </a> </li><br>
</ul>
{% endfor %}
{%for post in best_posts%}

{%endfor%}

这里的问题是什么

您是否将
媒体
视图添加到
URL.py
中了?否,如何添加请参见:是的,我现在添加了,但没有任何帮助?注意*如果我为它添加url,当我在浏览器中打开url时,它会工作,当我从url.py中删除url时,它会不工作为什么?我只想在其他html页面中显示它,比如include'ttest.html'