IT Blog

Slider vue 3

I added my simple slider using vue 3, that can switch image by mouse and finger touching. Also in this slider I use img for display of pictures,which is most often semantically correct, unlike div.

In this example I used typescript, script setup, module css.

<script setup lang="ts">
import { ref } from 'vue'

import Img1 from './1.jpg'
import Img2 from './2.jpg'
import Img3 from './3.jpg'

const slider = ref<HTMLElement | null>(null)
const images = ref([Img3, Img1, Img2])

const current_index = ref(0)
const position = ref(0)

let is_dragging = false
let prev_position = 0
let start_x = 0


How to fix double run testing with docker in Django

When I first switched to using docker and docker compose, Pycharm for some reason started running tests twice. Moreover, in the test debugging mode, testing was launched once, as expected.

The created containers when running the tests did not contain duplicate code on the file system, and Pycharm used the standard test run command:

/app/.venv/bin/python /opt/.pycharm_helpers/pycharm/ test --keepdb content.tests.ContentTest /opt/project/

At the same time, the tests were run only once if you went into the container and ran the tests with the usual command:

python test

I have 2 versions of the docker-compose.yml file: one for development and the...


pipenv with docker compose in PyCharm

At the moment of page publishing, PyCharm does not support pipenv with docker (issue: ). What is the problem?

As you know, Pipenv install requirements in different paths like /home/vivazzi/.local/share/virtualenvs/vivivys-pxi3oUGW/bin/python, where vivivys-pxi3oUG path generate differently in devending different factors. In other hand, Pycharm requires to specify concrete path to interpreter:

Note in this window we can not see generated path to interpreter, so in next window (click by ellipsis) we do not know what we should input:

If you input path to global interpreter (something like: /usr/bin/python or /usr/local/bin/python), you can create access to remote interpreter but your...


Override Config of Django app, extra django-cms migration is created

Sometimes you need to override Config for various reasons.

For example, in my case, after updating django 3.2+, a migration for django-cms was automatically created when you call makemigrations for your project.

It was in this error that this behavior arose due to the introduction of default_auto_field (see: ) and setting your DEFAULT_AUTO_FIELD to a value other than django.db.models.AutoField, namely django.db.models.BigAutoField. Therefore, when calling makemigrations, a migration was created in which the type of the ID field became BigAutoField for all django-cms models.

To fix the error above, you need to override CMSConfig in any of your...


Adding copy_relations outside of plugin using signals in django cms

In django-cms, it is sometimes necessary to add or extend copy_relations() in a third party plugin model to handle foreign keys: ForeignKey, OneToOneField или ManyToManyField.

For example, there is a certain third-party application (cms plugin) text_block with the TextBlock model:

class TextBlock(CMSPlugin):
    title = models.CharField(_('Title'), max_length=255)
    content = models.TextField(_('Content'))

class TextBlockPlugin(CMSPluginBase):
    model = TextBlock
    name = 'TextBlock'
    render_template = 'text_block.html'

And we need to add some extra field, for example, description.

To do this, add a new application to the project, for example, text_block_ext with the TextBlockExt model:

class TextBlockExt(models.Model):
    text_block =...

django-cms is not a function

In django 3.7.X (possibly in an earlier version) until current 3.8.0 (at the time of writing) has an error when opening the page structure:

`Uncaught TypeError: is not a function
at s.initialize (bundle.toolbar.min.js:1)

It occurs when the template has several static_placeholder with the same names, for example: {% static_placeholder 'header' %}.

There is an issue on Github, and developers have not fixed this case at this moment.

By digging around in the bundle.toolbar.min.js file where the error occurs, I was able to find a workaround.


Copy /path_to_env_of_my_project/lib/python3.8/site-packages/cms/static/cms/js/dist/3.8.0/bundle.toolbar.min.js file to /path_to_my_project/static/cms/js/dist/3.8.0/bundle.toolbar.min.js.

Note that instead of the 3.8.0...


django-select2 in Django

Immediately use django_select2 in the Django admin does not work because django_select2 requires jQuery. By default django_select2 widget does not include jQuery. You can read more about this on .

To quickly add jQuery to django_select2, do the following:


Key (extended_object_id) already exists.

When publishing a page in django-cms (3.5.0), an error may occur:

django.db.utils.IntegrityError: duplicate key value violates unique constraint "spec_pageext_extended_object_id_key"
DETAIL:  Key (extended_object_id)=(324) already exists.

From treysbeka it is clear that the error is related to Extension (PageExtension).

Still need to say that the error does not always appear when publishing the page. To reproduce the error you need:

  1. Create an extension (or "Save" in another way from Menu / Page / My extension)
  2. Publish page
  3. Go to the draft version by clicking "Edit"
  4. Remove extension (by going to Menu / Page / My extension and clicking "Delete")
  5. Create an extension...

'NoneType' object has no attribute 'get_all_fields' parler

If you create your own migration to add fields that must be translatable, you get error:

'NoneType' object has no attribute 'get_all_fields'

1 case. Update parler

In newer versions of parler, this error has been fixed, so it’s enough to upgrade the package.

2 case. Add TranslatableModelMixin in base class of model

Just addMyModel.__bases__ = (models.Model, TranslatableModelMixin) after declaration of MyModel.

For clarity, take an and add the necessary line:

from django.db import migrations
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist

def forwards_func(apps, schema_editor):
    MyModel = apps.get_model('myapp', 'MyModel')
    MyModel.__bases__ = (models.Model, TranslatableModelMixin)
    MyModelTranslation = apps.get_model('myapp', 'MyModelTranslation')...

Add jquery to widget Django

There is two simple ways to add jQuery to forms or widgets in django admin.

1. Adding of an other version of jQuery

Firstly, you need . As an example for this article I used . Place library, for example, here: my_project/static/jquery/jquery-2.2.0.min.js.


There is no search on this site, so I offer to use usual search engine, for example, Google, adding "vivazzi" after your request.

Try it

Select currency for displaying monetary values