Model Reference

ArchivedPage

class ArchivedPage

An full or partial HTML page archived for posterity

url

Required CharField(255) Unique

The URL path used now. You will likely configure this to be behind a prefix, like in Setting it up. Based on that example, if the URL value was /my/formerly/awesome/page.html, the full URL would be: http://example.com/archive/my/formerly/awesome/page.html

original_url

Required CharField(255)

The full original URL. This is important for rewriting the internal references to other resources. Django Vintage will rewrite links to other archived documents, if they’ve been archived, or the full URL if they don’t. It will also archive images and rewrite their URLs.

title

CharField(200)

The page title, typically from the <title> tag.

content

TextField

The content of the archived page. content can be any text. The content field is pre-rendered, as it stores links to other archived items using {% url %} and {{ STATIC_URL }} template tags and variables. No context is included in the rendering.

template

CharField(70)

The template to use when rendering this page. See How Django Vintage selects the template for more information on template selection.

metadata

ModelFormField( METADATA_FORM )

The metadata field is fundamentally a text field that stores JSON data. The data stored is flexible and determined via a Form set in METADATA_FORM.

relative_to_full_url()
Parameters:url (str) – A relative, full or fully-qualified URL.
Returns:A fully-qualified URL

This method converts a URL into a fully-qualified URL. Some internal methods use it to determine if a reference matches the original_url of any archived resource.

Returns:All the href attributes of every <a> tag in the content.
Return type:A list of str

A simple shortcut to get all the links referenced in the document. Links to other archived documents are formatted as {% url vintage_detail url=/url/path/ %}

Returns:All the href attributes of every <a> tag in the content that references an external resource.
Return type:A list of str

A simple shortcut to get all the external links referenced in the document. Very useful in deciding if there are more pages to archive.

Parameters:save (bool) – Default: True. Should you save the results.
Returns:None

Parse through the saved document and convert any external links that match an original_url to an internal reference.

By default, it will save the updated content. The save() method calls this every save.

update_images()
Parameters:save (bool) – Default: True. Should you save the results.
Returns:None

Parse through the saved document and convert any external <img> sources into ArchivedFile objects and update the reference.

By default, it will save the updated content. The save() method calls this every save.

get_original_image()
Parameters:path (str) – The URL of an image.
Returns:The internal URL

Retrieve an image referenced internally and create an ArchivedFile object, unless the fully-qualified URL matches the original_url of a ArchivedFile object.

save()

Each time an object is saved, the content is parsed for updates to links and images. If there isn’t an id, it is first saved, so new ArchivedFiles have something to reference.

ArchivedFile

class ArchivedFile

A non-html file used in an Archived Page, such as an image

archivedpage

Required ForeignKey( ArchivedPage ) Related Name: files

The document in which this file is referenced.

original_url

Required CharField(255)

The full original URL. This is important for rewriting the internal references to other resources.

content

FileField

The file is stored in the STORAGE setting and uploaded to vintage/<archivedpage.id>.

Project Versions

Table Of Contents

Previous topic

Settings

Next topic

Importing a page with process_url