Django-TOC Library API
- class tof.admin.ContentTypeAdmin(model, admin_site)[source]
Bases:
ModelAdmin- get_search_results(request, queryset, search_term)[source]
Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
- has_add_permission(*args, **kwargs)[source]
Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
- has_change_permission(*args, **kwargs)[source]
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.
- has_delete_permission(*args, **kwargs)[source]
Return True if the given request has permission to delete the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.
- property media
- search_fields = ('app_label', 'model')
- class tof.admin.LanguageAdmin(model, admin_site)[source]
Bases:
ModelAdmin- get_search_results(request, queryset, search_term)[source]
Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
- has_view_permission(request, obj=None)[source]
Return True if the given request has permission to view the given Django model instance. The default implementation doesn’t examine the obj parameter.
If overridden by the user in subclasses, it should return True if the given request has permission to view the obj model instance. If obj is None, it should return True if the request has permission to view any object of the given type.
- list_display = ('iso', 'is_active')
- list_editable = ('is_active',)
- property media
- search_fields = ('iso',)
- class tof.admin.StaticMessageTranslationAdmin(model, admin_site)[source]
Bases:
ActionViewsMixin,ModelAdmin- actions = (<function View.as_view.<locals>.view>, <function View.as_view.<locals>.view>)
- fields = ('message', 'translation')
- get_queryset(request)[source]
Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
- has_add_permission(request)[source]
Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
- has_change_permission(request, obj=None)[source]
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.
- has_delete_permission(request, obj=None)[source]
Return True if the given request has permission to delete the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.
- list_display = ('__str__', 'languages')
- property media
- readonly_fields = ('message', 'languages')
- search_fields = ('message', 'translation')
- class tof.admin.TranslatableFieldAdmin(model, admin_site)[source]
Bases:
ModelAdmin- class Media[source]
Bases:
object- css = {'screen': ('admin/css/empty_containers.css',)}
- js = ('tof/js/autocomplete_utils.js',)
- autocomplete_fields = ('content_type',)
- fieldsets = ((None, {'fields': ['content_type', 'name']}),)
- formfield_for_dbfield(db_field, request, **kwargs)[source]
Hook for specifying the form Field instance for a given database Field instance.
If kwargs are given, they’re passed to the form Field’s constructor.
- get_changeform_initial_data(request)[source]
Get the initial form data from the request’s GET params.
- get_queryset(request)[source]
Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
- get_search_results(request, queryset, search_term)[source]
Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
- has_change_permission(*args, **kwargs)[source]
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.
- list_display = ('content_type', 'name')
- property media
- search_fields = ('content_type__model', 'name')
- class tof.admin.TranslationAdmin(model, admin_site)[source]
Bases:
ModelAdmin- autocomplete_fields = ('field', 'lang')
- fieldsets = ((None, {'fields': (('field', 'lang'), 'object_id', 'value')}), ('hidden', {'classes': ['hidden'], 'fields': ['content_type']}))
- form
alias of
TranslationsForm
- list_display = ('content_object', 'lang', 'field', 'value')
- list_filter = ('content_type',)
- property media
- url_name = '%s:%s_%s_autocomplete'
- class tof.admin.TranslationFormSet(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)[source]
Bases:
BaseGenericInlineFormSet
- class tof.admin.TranslationInline(parent_model, admin_site)[source]
Bases:
TranslationInlineMixin,GenericInlineModelAdmin- property media
- class tof.admin.TranslationInlineMixin[source]
Bases:
object- autocomplete_fields = ('field', 'lang')
- extra = 0
- fields = ('field', 'lang', 'value')
- form
alias of
TranslationsInLineForm
- formset
alias of
TranslationFormSet
- property media
- model
alias of
Translation
- class tof.admin.TranslationStackedInline(parent_model, admin_site)[source]
Bases:
TranslationInline,GenericStackedInline- property media
- class tof.admin.TranslationTabularInline(parent_model, admin_site)[source]
Bases:
TranslationInline,GenericTabularInline- property media
- class tof.actions.GenerateTranslationJSONFileAction(**kwargs)[source]
Bases:
ActionView- allow_empty = True
- description = 'Generate translation JSON file for front'
- finished_message = 'Success'
- short_description = 'Generate translation JSON file for front'
- class tof.actions.VueI18NExtractAction(**kwargs)[source]
Bases:
ActionView- allow_empty = True
- description = 'Extract translation from front'
- finished_message = 'Success'
- short_description = 'Extract translation from front'
- class tof.apps.TofConfig(app_name, app_module)[source]
Bases:
AppConfig- default_auto_field = 'django.db.models.BigAutoField'
- name = 'tof'
- class tof.fields.TranslatableFieldFormField(fields, *args, **kwargs)[source]
Bases:
MultiValueField- clean(values)[source]
Validate every value in the given list. A value is validated against the corresponding Field in self.fields.
For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), clean() would call DateField.clean(value[0]) and TimeField.clean(value[1]).
- cleaned_langs = None
- compress(data_list)[source]
Return a single value for the given list of values. The values can be assumed to be valid.
For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), this might return a datetime object created by combining the date and time in data_list.
alias of
TranslatableFieldHiddenWidget
- widget
alias of
TranslatableFieldWidget
- class tof.forms.TranslationsForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]
Bases:
ModelForm- base_fields = {}
- declared_fields = {}
- property media
Return all media required to render the widgets on this form.
- class tof.forms.TranslationsInLineForm(*args, parent_object=None, **kwargs)[source]
Bases:
ModelForm- base_fields = {}
- declared_fields = {}
- property media
Return all media required to render the widgets on this form.
- class tof.mixins.InstancePatcherMixin[source]
Bases:
ClassPatcherMixin
- class tof.mixins.TofAdminMixin[source]
Bases:
InstancePatcherMixin
- class tof.mixins.TofInlineMixin[source]
Bases:
ClassPatcherMixin
- class tof.mixins.TranslationFieldMixin(*args, **kwargs)[source]
Bases:
ClassPatcherMixin
- class tof.mixins.TranslationFieldModelFormMixin(*args, **kwargs)[source]
Bases:
ClassPatcherMixin
- class tof.mixins.TranslationManagerMixin[source]
Bases:
InstancePatcherMixin
- tof.mixins.apply_mixins(patch, target_cls, fields)[source]
Add/remove to target_cls bases mixins, whose is necessary for work with tof.
- class tof.mixins.tofQ(*args, _connector=None, _negated=False, **kwargs)[source]
Bases:
Q- patch = True
- class tof.models.Language(id, iso, is_active)[source]
Bases:
Model- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_active
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- iso
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.ManagerFromLanguageQuerySet object>
- translations
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class tof.models.LanguageQuerySet(model=None, query=None, using=None, hints=None)[source]
Bases:
QuerySet
- class tof.models.StaticMessageTranslation(id, message, translation)[source]
Bases:
Model- CACHE = {}
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- base_translator_cls(message)
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- message
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.ManagerFromQuerySet object>
- save(*args, **kwargs)[source]
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.
- translation
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class tof.models.ThroughLanguage(*args, **kwargs)[source]
Bases:
Model- language
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.parentis aForwardManyToOneDescriptorinstance.
- language_id
- class tof.models.TranslatableField(id, name, content_type)[source]
Bases:
Model- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- content_type
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.parentis aForwardManyToOneDescriptorinstance.
- content_type_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.ManagerFromTranslatableFieldQuerySet object>
- replaced_field = None
- save(*args, **kwargs)[source]
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.
- translations
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- translator_cls
alias of
TranslatableText
- class tof.models.TranslatableFieldQuerySet(model=None, query=None, using=None, hints=None)[source]
Bases:
QuerySet
- class tof.models.Translation(id, content_type, object_id, field, lang, value)[source]
Bases:
Model- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- content_object
Provide a generic many-to-one relation through the
content_typeandobject_idfields.This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.
- content_type
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.parentis aForwardManyToOneDescriptorinstance.
- content_type_id
- field
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.parentis aForwardManyToOneDescriptorinstance.
- field_id
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- lang
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.parentis aForwardManyToOneDescriptorinstance.
- lang_id
- object_id
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.ManagerFromTranslationQueryset object>
- value
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class tof.models.TranslationQueryset(model=None, query=None, using=None, hints=None)[source]
Bases:
QuerySet
- class tof.utils.TranslatableText[source]
Bases:
strClass like a string but returns values depends on get_language.
- property DEFAULT
- property current
- property iter
- class tof.views.ActionView(**kwargs)[source]
Bases:
FormView- ADDITION = 1
- CHANGE = 2
- DELETION = 3
- admin = None
- allow_empty = False
- answer
- as_button = False
- callback_template = None
- callback_template_name_suffix = 'callback'
- cancel_message = 'Action was cancelled'
- counter = 0
- description = ''
- error_message = 'Error {cause}'
- extra_context = {'action_checkbox_name': '_selected_action'}
- finished_message = ''
- get(request, *args, **kwargs)[source]
Handle GET requests: instantiate a blank version of the form.
- get_form(form_class=None, **kwargs)[source]
Return an instance of the form to be used in this view.
- get_template_names()[source]
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
- logger
alias of
LogEntry
- model = None
- permissions = ()
- permissions_message_error = "You don't have enough permissions"
- post(request, *args, **kwargs)[source]
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.
- processing_message = '{} was change'
- queryset = None
- request = None
- setup(admin, request, queryset, *args, **kwargs)[source]
Initialize attributes shared by all view methods.
- short_description = ''
- template_button = 'core/action_button.html'
- template_name = 'core/confirmation.html'
- template_name_suffix = 'confirmation'
- class tof.views.YesNoForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]
Bases:
YesNoMixIn,Form- base_fields = {'answer': <django.forms.fields.ChoiceField object>}
- button_template = '<button type="{submit}" name="{name}" onclick="document.getElementById(`layer`).style.display = `block`;" value="{value}">{title}</button>'
- declared_fields = {'answer': <django.forms.fields.ChoiceField object>}
- property media
Return all media required to render the widgets on this form.
- prefix = 'YesNoForm'
- class tof.views.YesNoMixIn[source]
Bases:
object- CHOICES = (('yes', "Yes, I'm sure"), ('no', "No, I'm not sure"))
- NEGATIVE = 'no'
- NEGATIVE_TEXT = "No, I'm not sure"
- POSITIVE = 'yes'
- POSITIVE_TEXT = "Yes, I'm sure"
- answer_help_text = ''
- answer_label = ''
- button_negative_template = '<a href="#" class="button cancel-link">{title}</a>'
- button_template = '<button type="{submit}" name="answer" value="{value}">{title}</button>'
- form_template = 'core/extraform.html'
- is_positiv
- method = 'POST'
- process_url = ''
- class tof.widgets.TranslatableFieldHiddenWidget(attrs=None)[source]
Bases:
TranslatableFieldWidget- property media
Media for a multiwidget is the combination of all media of the subwidgets.
- class tof.widgets.TranslatableFieldWidget(widgets, attrs=None)[source]
Bases:
ValueFormatterMixin,MultiWidget- decompress(value)[source]
Return a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
- id_for_label(id_)[source]
Return the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Return an empty string if no ID is available.
This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this method should return an ID value that corresponds to the first ID in the widget’s tags.
- input_type = 'text'
- property media
Media for a multiwidget is the combination of all media of the subwidgets.
- template_name = 'tof/multiwidget.html'