Table Of Contents

This Page

Provided template tags

attachments.py

class files.templatetags.attachments.AttachmentCountNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Insert a count of attachments into the context

class files.templatetags.attachments.AttachmentEditFormNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Insert a form for the attachment model instance into the context

class files.templatetags.attachments.AttachmentFormNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Insert a form for the attachment model into the context

class files.templatetags.attachments.AttachmentListNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Insert a list of attachments into the context

class files.templatetags.attachments.BaseAttachmentNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Base helper class for handling the get_attachment_* template tags. Modelled after the contrib.comments framework

get_context_value_from_queryset(context, qs)

Subclasses should override this.

classmethod handle_token(parser, token)

Class method to parse get_attachment_list/count/form and return a Node

class files.templatetags.attachments.RenderAttachmentEditFormNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Render the edit form directly

class files.templatetags.attachments.RenderAttachmentFormNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Render the attachment form directly

classmethod handle_token(parser, token)

Class method to parse render_comment_form and return a Node.

class files.templatetags.attachments.RenderAttachmentListNode(ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, attachment=None)

Render the attachment list directly

classmethod handle_token(parser, token)

Class method to parse render_attachment_list and return a Node.

files.templatetags.attachments.get_attachment_count(parser, token)

Gets the attachment 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_attachment_count for [object] as [varname]  %}
{% get_attachment_count for [app].[model] [object_id] as [varname]  %}

Example usage:

{% get_attachment_count for event as comment_count %}
{% get_attachment_count for calendar.event event.id as comment_count %}
{% get_attachment_count for calendar.event 17 as comment_count %}
files.templatetags.attachments.get_attachment_editform(parser, token)

Get a modelform object to edit an existing attachment.

Syntax:

{% get_attachment_editform for [object] as [varname] %}
{% get_attachment_editform for [app].[model] [object_id] as [varname] %}
files.templatetags.attachments.get_attachment_form(parser, token)

Get a (new) form object to upload a new attachment.

Example usage:

{% get_attachment_form for [object] as [varname] %}
{% get_attachment_form for [app].[model] [object_id] as [varname] %}
files.templatetags.attachments.get_attachment_list(parser, token)

Gets the list of attachments 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_attachment_list for [object] as [varname]  %}
{% get_attachment_list for [app].[model] [object_id] as [varname]  %}

Example usage:

{% get_attachment_list for event as attachment_list %}
{% for attachment in attachment_list %}
    ...
{% endfor %}
files.templatetags.attachments.get_create_target()

Get the target URL for the attachment form.

Example:

<form action="{% get_create_target %}" method="post">
files.templatetags.attachments.get_delete_url(attachment)

Get the delete URL for an attachment.

Example:

<a href="{% get_delete_url attachment %}">delete</a>
files.templatetags.attachments.get_download_url(attachment)

Get the download URL for an attachment.

Example:

<a href="{% get_download_url attachment %}">download</a>
files.templatetags.attachments.get_edit_target(attachment)

Get the edit URL for an attachment.

Example:

<a href="{% get_edit_target attachment %}">edit</a>
files.templatetags.attachments.get_edit_url(attachment)

Get the edit URL for an attachment.

Example:

<a href="{% get_edit_url attachment %}">edit</a>
files.templatetags.attachments.get_view_url(attachment)

Get the view URL for an attachment.

Example:

<a href="{% get_view_url attachment %}">view</a>
files.templatetags.attachments.render_attachment_editform(parser, token)

Render the attachment form (as returned by {% render_attachment_editform %}) through the attachments/editform.html template.

Syntax:

{% render_attachment_editform for [object] %}
{% render_attachment_editform for [app].[model] [object_id] %}
files.templatetags.attachments.render_attachment_form(parser, token)

Render the attachment form (as returned by {% render_attachment_form %}) through the attachments/form.html template.

Syntax:

{% render_attachment_form for [object] %}
{% render_attachment_form for [app].[model] [object_id] %}
files.templatetags.attachments.render_attachment_list(parser, token)

Render the attachment list (as returned by {% get_attachment_list %}) through the attachments/list.html template

Syntax:

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

Example usage:

{% render_attachment_list for event %}