#23422: Cannot add Permission to Group in data migration
----------------------------+--------------------
     Reporter:  tjwalch     |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.7
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 As initial_data fixtures are now deprecated I want to move my things there
 to migration files instead. One thing I do is to create auth.Group(s) and
 give these some custom permissions that I have defined on the app's
 models. This does not seem to be possible as, from what I can tell, the
 permissions and content types are created in a signal AFTER all the
 Migrations are run. Neither custom nor standard permissions can be found.

 A Group and its permissions are data and the initialization thereof should
 therefore be possible to achieve through the migration system since its
 supposed to replace the fixtures.

 {{{
 my_new_group.permissions.add(
     Permission.objects.get_by_natural_key('add_my_model', 'my_app',
 'my_model')
 )
 }}}

 This gives:

 {{{
 django.contrib.contenttypes.models.DoesNotExist: ContentType matching
 query does not exist.
 }}}

 even though I created the model in the previous migration step. There are
 no ContentTypes ate all yet.

--
Ticket URL: <https://code.djangoproject.com/ticket/23422>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.80538ebe2616da85d6c4003ff48b2a7d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to