Each FileNode instance represents a node in the media object tree, that is to say a “file” or “folder”. Accordingly, their node_type attribute can either be FileNode.FOLDER, meaning that they may have child nodes, or FileNode.FILE, meaning that they are associated to media files in storage and are storing metadata about those files.
Note
Since FileNode is a child class of MPTTModel, it inherits many methods that facilitate queries and data manipulation when working with trees.
You can access the actual media associated to a FileNode model instance using the following to field attributes:
Returns object metadata suitable for use as the HTML alt attribute. You can use this method in templates:
<img src="{{ node.file.url }}" alt="{{ node.alt }}" />
Author name of the file
Copyright information for the file
Date and time when object was created
User that created the object
Date and time information for the file (authoring or publishing date)
Description for the file
File extension, lowercase
Extra metadata
Returns the URL for viewing a FileNode in the admin.
Creates a QuerySet containing the ancestors of this model instance.
This defaults to being in descending order (root ancestor first, immediate parent last); passing True for the ascending argument will reverse the ordering (immediate parent first, root ancestor last).
If include_self is True, the QuerySet will also include this model instance.
Returns object metadata that has been selected to be displayed to users, compiled as a string including default formatting, for example bold titles.
You can use this method in templates where you want to output image captions.
Returns object metadata that has been selected to be displayed to users, compiled as a string with the original field values left unescaped, i.e. the original field values may contain tags.
Returns a QuerySet containing the immediate children of this model instance, in tree order.
The benefit of using this method over the reverse relation provided by the ORM to the instance’s children is that a database query can be avoided in the case where the instance is a leaf node (it has no children).
If called from a template where the tree has been walked by the cache_tree_children filter, no database query is required.
Returns the number of descendants this model instance has.
Creates a QuerySet containing descendants of this model instance, in tree order.
If include_self is True, the QuerySet will also include this model instance.
Creates a QuerySet containing leafnodes of this model instance, in tree order.
If include_self is True, the QuerySet will also include this model instance (if it is a leaf node)
Returns the level of this node (distance from root)
Returns object metadata that has been selected to be displayed to users, compiled as a string.
Returns object metadata that has been selected to be displayed to users, compiled as a string with the original field values left unescaped, i.e. the original field values may contain tags.
Returns this model instance’s next sibling in the tree, or None if it doesn’t have a next sibling.
Returns this model instance’s previous sibling in the tree, or None if it doesn’t have a previous sibling.
Returns a fully qualified URL for the file field, including protocol, domain and port. In most cases, you can just use file.url instead, which (depending on your MEDIA_URL) may or may not contain the domain. In some cases however, you always need a fully qualified URL. This includes, for instance, embedding a flash video player from a remote domain and passing it a video URL.
Similar to get_qualified_file_url(), but returns the URL for the preview_file field, which can be used to associate image previews with video files.
Returns the root node of this model instance’s tree.
Creates a QuerySet containing siblings of this model instance. Root nodes are considered to be siblings of other root nodes.
If include_self is True, the QuerySet will also include this model instance.
Returns a symbolic node representing the root of all nodes. This node is not actually stored in the database, but used in the admin to link to the change list.
Flag specifying whether the absolute minimal metadata was entered
For images: height in pixels
Convenience method for calling TreeManager.insert_node with this model instance.
Returns True if this model is an ancestor of the given node, False otherwise. If include_self is True, also returns True if the two nodes are the same node.
Returns True if this model instance is a child node, False otherwise.
Flag whether the file is the default file in its parent folder
Returns True if this model instance is a leaf node (it has no children), False otherwise.
Returns True if this model instance is a root node, False otherwise.
Returns True if the model instance is the top node.
Keywords for the file
Media type, i.e. broad category of the kind of media
The mime type of the media file
Date and time when object was last modified
User that last modified the object
Convenience method for calling TreeManager.move_node with this model instance.
NOTE: This is a low-level method; it does NOT respect MPTTMeta.order_insertion_by. In most cases you should just move the node yourself by setting node.parent.
Name of the file or folder
Type of the node (FileNode.FILE or FileNode.FOLDER)
Alt text override. If empty, the alt text will be compiled from the all metadata that is available and flagged to be displayed.
Caption override. If empty, the caption will be compiled from the all metadata that is available and flagged to be displayed.
The parent (folder) object of the node.
Position of the file among its siblings, for manual ordering
Flag to toggle whether the author name should be displayed
Flag to toggle whether copyright information should be displayed
Flag to toggle whether date and time information should be displayed
Publish date and time
File size in bytes
Slug for the object
Title for the file
For images: width in pixels