IT Blog

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.


Highcharts redraw diagrams

Typically, highcharts graphics are automatically redrawn when the browser window is changed, but sometimes you need to forcefully redraw graph.

Intuition suggests you need to use .redraw() method, but, alas, it probably will not work (as it happended with me). For example, I had to redraw diagram after minimizing of left menu bar. When the menu collapses or unfolds, then width of div changes, and it need to automatically adjust the graphics to new width.

To redraw the highcharts diagrams, use .reflow() method:

$('..close').on('click.chart', function () {  // add click event on minimize menu button
    var $sb_chart = $('.sb_chart');

tar archive

tar archive creation

tar -cvf file.tar /path/to/file_or_folder/   # create .tar

With .tar.gz and .tar.bz2 formats you can use the compression:

tar -czvf file.tar.gz /path/to/file_or_folder/   # create .tar.gz (popular)
tar -cjvf file.tar.bz2 /path/to/file_or_folder/   # create .tar.bz2

Extract .tar archive

tar -xvf file.tar.gz

Keys of tar command

-c - to create archive
-v - listing of handled files
-f - working with file
-z - archive compression with gzip
-j - archive compression with bzip2
-x - file extract from archive
-C - to go to folder (look more detail below)

More details with compression

Do you note that when you extract...

  • Page 1 from 2
  • Pages:
  • 1
  • 2
  • Next

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