Задать вопрос

Тел: +7 965 3737 888

425

Просмотров

0

Ответов

View decorator to automate templates.

<p>Place the above code in your view, and then you can use it to specify what template to use.  Set elements of the context as a dictionary and that gets passed to the template as well.  For example:</p>
<p>In view.py:</p>
####################################
@with_template('friends/index.html')
def friends(request, context, username):
   context['user'] = User.objects.get(username = username)

<p>in friends/index.html:</p>
{% extends "base.html" %}
{% block content %}
&lt;h1&gt;{{ user.username }}'s Friends&lt;/h1&gt;

Вопрос полезен? Да0/Нет0
file_3785.py(356.0б)
None