Template tags¶
Base helper class (abstract) for handling the get_review_* template tags. Looks a bit strange, but the subclasses below should make this a bit more obvious.
Subclasses should override this.
Class method to parse get_review_list/count/form and return a Node.
Return the node rendered as a string.
Insert a rating weighted average into the context.
Subclasses should override this.
Render the rating weighted average directly
Class method to parse render_rating and return a Node.
Return the node rendered as a string.
Render the review form directly
Class method to parse render_review_form and return a Node.
Return the node rendered as a string.
Render the review list directly
Class method to parse render_review_list and return a Node.
Return the node rendered as a string.
Insert a user review into the context.
Subclasses should override this.
Insert a count of reviews into the context.
Subclasses should override this.
Insert a form for the review model into the context.
Return the node rendered as a string.
Insert a list of reviews into the context.
Subclasses should override this.
Gets the average rating for the given params and populates the template context with a variable containing that value, whose name is defined by the ‘as’ clause.
Syntax:
{% get_rating for [object] as [varname] %} {% get_rating for [app].[model] [object_id] as [varname] %}
Example usage:
{% get_rating for product as avg_rating %} {% get_rating for shop.product product.id as avg_rating %} {% get_rating for shop.product 17 as avg_rating %}
Gets the current user review for the given params and populates the template context with a variable containing that value, whose name is defined by the ‘as’ clause.
Syntax:
{% get_review_by_user for [object] as [varname] %} {% get_review_by_user for [app].[model] [object_id] as [varname] %}
Example usage:
{% get_review_by_user for product as user_review %}
Gets the review count for the given params and populates the template context with a variable containing that value, whose name is defined by the ‘as’ clause.
Syntax:
{% get_review_count for [object] as [varname] %} {% get_review_count for [app].[model] [object_id] as [varname] %}
Example usage:
{% get_review_count for product as review_count %} {% get_review_count for shop.product product.id as review_count %} {% get_review_count for shop.product 17 as review_count %}
Get a (new) form object to post a new review.
Syntax:
{% get_review_form for [object] as [varname] %} {% get_review_form for [app].[model] [object_id] as [varname] %}
Gets the list of reviews for the given params and populates the template context with a variable containing that value, whose name is defined by the ‘as’ clause.
Syntax:
{% get_review_list for [object] as [varname] %} {% get_review_list for [app].[model] [object_id] as [varname] %}
Example usage:
{% get_review_list for product as review_list %} {% for review in review_list %} ... {% endfor %}
Get the permalink for a review, optionally specifying the format of the named anchor to be appended to the end of the URL.
- Example::
- {% get_review_permalink review “#r%(id)s-by-%(user_name)s” %}
Render the rating (as returned by
{% get_rating %}
) through thereviews/rating.html
templateSyntax:
{% render_rating for [object] %} {% render_rating for [app].[model] [object_id] %}
Example usage:
{% render_rating for product %}
Render exact rating through the
reviews/rating_value.html
templateSyntax:
{% render_rating_value [number] %}
Example usage:
{% render_rating_value review.rating %}
Render the review form (as returned by
{% render_review_form %}
) through thereviews/form.html
template.Syntax:
{% render_review_form for [object] %} {% render_review_form for [app].[model] [object_id] %}
Render the review list (as returned by
{% get_review_list %}
) through thereviews/list.html
templateSyntax:
{% render_review_list for [object] %} {% render_review_list for [app].[model] [object_id] %}
Example usage:
{% render_review_list for product %}
Get the target URL for the review form.
Example:
<form action="{% review_form_target %}" method="post">