create_referral
Use this tag to render a form that allows users to generate a referral link. The form is designed for AJAX submission and returns JSON.
Usage:
{% load pinax_referrals_tags %}
{# To link to a specific object: #}
{% create_referral object.get_absolute_url object %}
{# To link to a specific URL: #}
{% url my_named_url as myurl %}
{% create_referral myurl %}
Recommended JavaScript (using jquery.form):
$(function () {
$('form.referral').each(function(i, e) {
var form = $(e);
var options = {
dataType: "json",
success: function(data) {
form.html('<input type="text" value="' + data.url + '" />');
form.find("input[type=text]").select();
}
};
form.ajaxForm(options);
});
});
referral_responses
An assignment tag that sets a context variable to a queryset of all responses for all referrals owned by a specific user, ordered by creation date.
Usage:
{% load pinax_referrals_tags %}
{% referral_responses user as responses %}
{% for response in responses %}
{# response is a ReferralResponse object #}
{% endfor %}
action_display filter
Converts a response action code into user-friendly text based on the PINAX_REFERRALS_ACTION_DISPLAY setting.
Usage:
{% load pinax_referrals_tags %}
<p>{{ response.action|action_display }}</p>