basxbread.contrib.document_templates package

Submodules

basxbread.contrib.document_templates.models module

class basxbread.contrib.document_templates.models.DocumentTemplate(id, name, file, model, filename_template)

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

all_used_fonts()
context(object)
default_context()
file

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
filename_template

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

generate_document(object, extension)
generate_document_pdf(object)
generate_document_url(obj: Lazy | Model, pdf=False)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

missing_variables()

Returns (variables_only_in_template, variables_only_in_definition)

model

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

model_id
name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
render_with(object)
save(*args, **kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

variables

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class basxbread.contrib.document_templates.models.DocumentTemplateVariable(id, document_template, name, value, template, raw_value)

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

document_template

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

document_template_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
raw_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

template

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

basxbread.contrib.document_templates.urls module

basxbread.contrib.document_templates.views module

class basxbread.contrib.document_templates.views.DocumentTemplateEditView(*args, **kwargs)

Bases: EditView

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

get_success_url()

Return the URL to redirect to after processing a valid form.

basxbread.contrib.document_templates.views.generate_document_download(request, pk: int, object_pk: int)
basxbread.contrib.document_templates.views.generate_document_download_pdf(request, pk: int, object_pk: int)