Good afternoon! I'm using the verbose_name_plural dynamic field to show some up-to-date information in the admin panel. Django version: 4.1 The model looks like this:
from django.utils.functional import lazy
from django.utils.translation import gettext_lazy as _
class Post(models.Model):
# ...
class Meta:
verbose_name = 'Post'
verbose_name_plural = lazy(lambda: _('Posts ({})').format(Post.....count()), str)()
I don't remember where I found this option to display some information, but it works great, except that every time the value changes and the command to create migrations is run, I get something like this:
from django.db import migrations
class Migration(migrations.Migration):
operations = [
migrations.AlterModelOptions(
name='post',
options={'verbose_name': 'Post', 'verbose_name_plural': 'Posts (123)'},
),
]
I found this option: https://stackoverflow.com/a/39801321/2166371 But I don’t know how relevant it is and why a class that is not used is imported there