Template tags

class reviews.templatetags.reviews.BaseReviewNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

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.

get_context_value_from_queryset(context, qs)[source]

Subclasses should override this.

classmethod handle_token(parser, token)[source]

Class method to parse get_review_list/count/form and return a Node.

render(context)[source]

Return the node rendered as a string.

class reviews.templatetags.reviews.RatingAverageNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

Insert a rating weighted average into the context.

get_context_value_from_queryset(context, qs)[source]

Subclasses should override this.

class reviews.templatetags.reviews.RenderRatingAverageNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

Render the rating weighted average directly

classmethod handle_token(parser, token)[source]

Class method to parse render_rating and return a Node.

render(context)[source]

Return the node rendered as a string.

class reviews.templatetags.reviews.RenderReviewFormNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

Render the review form directly

classmethod handle_token(parser, token)[source]

Class method to parse render_review_form and return a Node.

render(context)[source]

Return the node rendered as a string.

class reviews.templatetags.reviews.RenderReviewListNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

Render the review list directly

classmethod handle_token(parser, token)[source]

Class method to parse render_review_list and return a Node.

render(context)[source]

Return the node rendered as a string.

class reviews.templatetags.reviews.ReviewByUserNode(*args, **kwargs)[source]

Insert a user review into the context.

get_context_value_from_queryset(context, qs)[source]

Subclasses should override this.

class reviews.templatetags.reviews.ReviewCountNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

Insert a count of reviews into the context.

get_context_value_from_queryset(context, qs)[source]

Subclasses should override this.

class reviews.templatetags.reviews.ReviewFormNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

Insert a form for the review model into the context.

render(context)[source]

Return the node rendered as a string.

class reviews.templatetags.reviews.ReviewListNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, review=None)[source]

Insert a list of reviews into the context.

get_context_value_from_queryset(context, qs)[source]

Subclasses should override this.

reviews.templatetags.reviews.get_rating(parser, token)[source]

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 %}
reviews.templatetags.reviews.get_review_by_user(parser, token)[source]

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 %}
reviews.templatetags.reviews.get_review_count(parser, token)[source]

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 %}
reviews.templatetags.reviews.get_review_form(parser, token)[source]

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] %}
reviews.templatetags.reviews.get_review_list(parser, token)[source]

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” %}
reviews.templatetags.reviews.render_rating(parser, token)[source]

Render the rating (as returned by {% get_rating %}) through the reviews/rating.html template

Syntax:

{% render_rating for [object] %}
{% render_rating for [app].[model] [object_id] %}

Example usage:

{% render_rating for product %}
reviews.templatetags.reviews.render_rating_value(value)[source]

Render exact rating through the reviews/rating_value.html template

Syntax:

{% render_rating_value [number] %}

Example usage:

{% render_rating_value review.rating %}
reviews.templatetags.reviews.render_review_form(parser, token)[source]

Render the review form (as returned by {% render_review_form %}) through the reviews/form.html template.

Syntax:

{% render_review_form for [object] %}
{% render_review_form for [app].[model] [object_id] %}
reviews.templatetags.reviews.render_review_list(parser, token)[source]

Render the review list (as returned by {% get_review_list %}) through the reviews/list.html template

Syntax:

{% render_review_list for [object] %}
{% render_review_list for [app].[model] [object_id] %}

Example usage:

{% render_review_list for product %}
reviews.templatetags.reviews.review_form_target()[source]

Get the target URL for the review form.

Example:

<form action="{% review_form_target %}" method="post">