def detail(request,x_id):
try:
album = X.objects.get(pk=x_id)
except X.DoesNotExist:
raise Http404("X Does NOt Exist")
return render(request, 'abc/abc.html', {'x':x})
When I try to access it on the browser it just shows x object. Not the attributes it has.
当我尝试在浏览器*问它时,它只显示了x对象。不是它的属性。
abc.html has just this: {{x}}
美国广播公司(abc)。html只有这个:{x}
1 个解决方案
#1
1
To access atribute of x
object you have to write x.object_atribute
in your html
file. So for example if you send book object
to your html that has author
, title
attributes you have to write something like:
要访问x对象的atribute,你必须写x。object_atribute在html文件中。例如,如果你将book对象发送到有作者,标题属性的html中你必须写如下内容:
<ul> <li>{{ book.title }}</li> <li>{{ book.author }}</li> </ul>
< ul > <李> { {书。李李标题} } < / > < > { {书。作者} } < /李> < / ul >
#1
1
To access atribute of x
object you have to write x.object_atribute
in your html
file. So for example if you send book object
to your html that has author
, title
attributes you have to write something like:
要访问x对象的atribute,你必须写x。object_atribute在html文件中。例如,如果你将book对象发送到有作者,标题属性的html中你必须写如下内容:
<ul> <li>{{ book.title }}</li> <li>{{ book.author }}</li> </ul>
< ul > <李> { {书。李李标题} } < / > < > { {书。作者} } < /李> < / ul >