#26756: Changing of model's verbose_name does not change the names of the 
model's
permissions
-------------------------------------+-------------------------------------
     Reporter:  dburakov             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.9
     Severity:  Normal               |               Resolution:
     Keywords:  permissions          |             Triage Stage:
  verbose_name migrate               |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by dburakov):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Old 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"
> }}}
>

> 2. Run "makemigrations" and than "migrate"
> 3. 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
> }}}
>

> 4. Change the "verbose_name" of the Meta class of the model
>

> {{{
> class AwesomeModel(models.Model):
>     class Meta:
>         verbose_name = "My really awesome model"
> }}}
>

> 5. Run "makemigrations" and than "migrate" again
> 6. 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
> }}}

New 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"
 }}}


 2. Run "makemigrations" and than "migrate"
 3. 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
 }}}


 4. Change the "verbose_name" of the Meta class of the model


 {{{
 class AwesomeModel(models.Model):
     class Meta:
         verbose_name = "My really awesome model"
 }}}


 5. Run "makemigrations" and than "migrate" again
 6. 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 my really awesome model     |               2 |
 change_awesomemodel
    3 | Can delete my really awesome model     |               2 |
 delete_awesomemodel
 }}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/26756#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.638f5cb65ad1fc85564526a5d3cd0f66%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to