Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何解决django.template.exceptions.TemplateSyntaxError_Python_Django_Django Models_Django Views_Django Templates - Fatal编程技术网

Python 如何解决django.template.exceptions.TemplateSyntaxError

Python 如何解决django.template.exceptions.TemplateSyntaxError,python,django,django-models,django-views,django-templates,Python,Django,Django Models,Django Views,Django Templates,我试图从我的数据库中获取一些特定的日期,并将它们传递到模板中。 但我得到了这个错误: django.template.exceptions.TemplateSyntaxError:无法分析 余数:“条目中的ent”来自“条目中的ent” my views.py: entries = Entry.objects.filter(user=request.user) return render(request, 'user.html', {'user':user.title(), 'time':tim

我试图从我的数据库中获取一些特定的日期,并将它们传递到模板中。 但我得到了这个错误:

django.template.exceptions.TemplateSyntaxError:无法分析 余数:“条目中的ent”来自“条目中的ent”

my views.py:

entries = Entry.objects.filter(user=request.user)
return render(request, 'user.html', {'user':user.title(), 'time':time, 'entries':entries})
my models.py:

from django.db import models
from django.contrib.auth.models import User


class Entry(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    date = models.DateTimeField()
    content = models.CharField(max_length=20000)
    def __str__(self):
        return self.content
user.html:

 {{for ent in entries}}
            <div id="sect">
                <div id="date" name='date'>
                    {{ent.date}}
                </div>
            </div>
        {{% endfor %}}
{{for entry in entries}
{{ent.date}
{{%endfor%}}

这是你在这里犯的一个简单的打字错误 用这个

{%for entries%}
{{ent.date}
{%endfor%}

在for循环中使用百分比

Ohh..我觉得自己太蠢了..谢谢你兄弟..@Kishan Parmar
{% for ent in entries %}
        <div id="sect">
            <div id="date" name='date'>
                {{ent.date}}
            </div>
        </div>
    {% endfor %}