Skip to content

Meringue core¤

This is a basic package that contains a variety of general purpose functionality such as abstract models, various handlers, utilities, and more.

Mixins¤

CMTimeMixin¤

A primitive abstract model that adds the ctime and mtime fields to your model.

SortingMixin¤

An abstract model that adds a sortable field, as well as a manager with sorting correction functionality.

correction_sorting¤

This is a method to update/fix the sorting of the selected list of items.

The sorting will be done according to the queryset sorting, so sorting can be controlled by executing .order_by() before calling the correction_sorting method.

The selection for updating sorting can be pre-limited by filtering the list.

PublicationMixin¤

Mixin with the functionality of manual publishing.

Examples:

>>> FooModel.object.published()
>>> FooModel.object.unpublished()

published¤

Method to getting published items.

unpublished¤

Method for getting unpublished items.

PublicationDatesMixin¤

Mixin with the functionality of publishing in a certain period.

Examples:

>>> FooModel.object.published()
>>> FooModel.object.unpublished()

published¤

Method to getting published items.

unpublished¤

Method for getting unpublished items.

Utils¤

format_date_from_to¤

Method to display date period.

Possible output formats depending on the input data:

  • DD.MM.YYYY - DD.MM.YYYY
  • DD.MM - DD.MM.YYYY
  • DD - DD.MM.YYYY
  • DD.MM.YYYY

Examples:

>>> print(format_date_from_to(dt.date(2020, 1, 1), dt.date(2020, 2, 1)))
01.01 - 01.02.2020

Attributes:

  • date_start

    Period start date.

  • date_end

    Period end date.

  • delimiter

    Dates delimiter.

Returns:

  • str

    Date period string.

Templatetags¤

cop_year¤

A tag that displays the year or range of years for the copyright string in YYYY-YYYY format.

For the tag to work, you must fill in the COP_YEAR parameter in the settings.

Examples:

<p>Copyright © {% cop_year %} My company</p>

Raises:

  • Exception

    To use the cop_year tag, you must fill in the COP_YEAR parameter in the meringue settings

Returns:

  • str

    Year for copyrights.

date_range¤

return range of date in one of the following formats

DD.MM.YYYY - DD.MM.YYYY DD.MM - DD.MM.YYYY DD - DD.MM.YYYY DD.MM.YYYY

Attributes:

  • date_start

    Period start date.

  • date_end

    Period end date.

Examples:

{% date_range date_start date_end %}

Returns:

  • str

    Date period.

Translations¤

If you use djano-modeltranslation, then when connecting meringue.core, you can register fields for translations by setting the list of fields in the m_translate_fields field in the meta of the corresponding model:

class FooModel(models.Model):
    name = models.CharField(max_length=32)

    class Meta:
        m_translate_fields = ["name", ]

Views¤

im_a_teapot¤

We all at some point want to brew boiling water.

Examples:

urls.py
from django.urls import path
from meringue.core.views import im_a_teapot

urlpatterns = [
    path('make_coffee', im_a_teapot, name="make_coffee"),
]

Last update: 2023-07-02 17:04:25+0000
Created: 2023-06-24 12:29:38+0000
Authors: dd