I
I
Igor2019-03-26 23:44:32
Django
Igor, 2019-03-26 23:44:32

How to update model name in permission from auth in Django?

Good afternoon!
Recently, while looking at the list of permissions in the admin panel, I found that the model names in the permissions are outdated .
5c9a84ac8246e794578123.png

Here instead of a word Предметthere is a word Товар, and instead of a word Квант -quant

I, for a short time, decided to look at the database through DB Browser for SQLite(browser for SQLite) and found that the model names in the permission table (auth_permission) are stored directly in the database , and are not taken from the code.
5c9a8b642bb7e276905175.png
From all of the above, I learned that the model names in the permissions were generated during the first migration .
Question: how can I update the model names in the permissions to the current state?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2019-05-07
@Igorello74

In general, I solved the problem as follows:

  1. Remove all permissions manually:
    • or via shell Django ( python3 manage.py shell)
      from django.contrib.auth.models import Permission
      Permission.objects.all().delete()

    • Make and apply migration:
      python3 manage.py makemigrations
      python3 manage.py migrate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question