Opened 9 years ago

Last modified 4 years ago

#26756 new Bug

Changing of model's verbose_name does not change the names of the model's permissions — at Initial Version

Reported by: Dmitry Burakov Owned by: nobody
Component: contrib.auth Version: dev
Severity: Normal Keywords: permissions verbose_name migrate
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I've found that changing the "verbose_name" of the Meta class of a model and than running migrations does not change the names of the model's permissions.

Steps to reproduce:

  1. Create a new model
class AwesomeModel(models.Model):
    class Meta:
        verbose_name = "My awesome model"
  1. Run "makemigrations" and than "migrate"
  2. Look at the generated permissions
select * from auth_permission;
 id  |                  name                  | content_type_id |             codename
-----+----------------------------------------+-----------------+----------------------------------
   1 | Can add my awesome model               |               2 | add_awesomemodel
   2 | Can change my awesome model            |               2 | change_awesomemodel
   3 | Can delete my awesome model            |               2 | delete_awesomemodel
  1. Change the "verbose_name" of the Meta class of the model
class AwesomeModel(models.Model):
    class Meta:
        verbose_name = "My really awesome model"
  1. Run "makemigrations" and than "migrate" again
  2. Look at the generated permissions agaun
select * from auth_permission;
 id  |                  name                  | content_type_id |             codename
-----+----------------------------------------+-----------------+----------------------------------
   1 | Can add my awesome model               |               2 | add_awesomemodel
   2 | Can change my awesome model            |               2 | change_awesomemodel
   3 | Can delete my awesome model            |               2 | delete_awesomemodel

As you can see the names of the model's permissions are not changed.
But! If now you drop the database and apply all the migrations to the empty database - the permissions will have correct names

select * from auth_permission;
 id  |                  name                  | content_type_id |             codename
-----+----------------------------------------+-----------------+----------------------------------
   1 | Can add my really awesome model        |               2 | add_awesomemodel
   2 | Can change really my awesome model     |               2 | change_awesomemodel
   3 | Can delete really my awesome model     |               2 | delete_awesomemodel

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top