Reputation: 173
def func_view(request,id):
post = get_object_or_404(Post, pk=id, user=request.user)
return render_to_response('post.html',
{'post': post},
RequestContext(request))
in my template:
<div id="post-data">
{{ post.name }}
{{ post.date }}
{{ post.extra }}
</div>
How to create something like this: If my {{ post.extra }}
is empty in database -> displaying information "Extra is empty" ?
Upvotes: 0
Views: 330
Reputation: 27581
Or use use filter default
:
{{ post.extra|default:"Extra is empty" }}
Upvotes: 5
Reputation: 8251
You can use built-in helpers:
{% if post.extra %}
{{ post.extra }}
{% else %}
Extra is empty
{% endif %}
Upvotes: 4