Re: [Django] #23422: Cannot add Permission to Group in data migration

2021-07-23 Thread Django
#23422: Cannot add Permission to Group in data migration
-+--
 Reporter:  Tomas Walch  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Migrations   |  Version:  1.7
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--

Comment (by wkleinheerenbrink):

 The `emit_post_migrate_signal` is not a complete safe way, for this might
 cause other post migrate in apps to be triggered as well that now expect
 their tables to exist while they don't yet. For instance the Sites
 framework will run `create_default_site` in post migrate, causing this
 error.

 Other solutions are proposed in:
   * https://stackoverflow.com/questions/31735042/adding-django-admin-
 permissions-in-a-migration-permission-matching-query-does-n
   * https://stackoverflow.com/questions/57958722/django-python-loaddata-
 fails-with-django-db-utils-integrityerror

 Do note that these solutions required a dependency of migration
 `("contenttypes", "0002_remove_content_type_name")` since Django 3.2.5.

-- 
Ticket URL: 
Django 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.f2515404ff868a84e26962213dfaa590%40djangoproject.com.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2020-05-07 Thread Django
#23422: Cannot add Permission to Group in data migration
-+--
 Reporter:  Tomas Walch  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Migrations   |  Version:  1.7
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--

Comment (by Floréal Cabanettes):

 Replying to [comment:20 Alan Justino da Silva]:

 It still works with django 2.2 with some few changes:


 {{{
 from django.core.management.sql import emit_post_migrate_signal

 def create_group(apps, schema_editor):
 emit_post_migrate_signal(2, False, 'default')
 Group = apps.get_model('auth', 'Group')
 Permission = apps.get_model('auth', 'Permission')
 (...)
 }}}

 Thank you, because else, I can't use migration for that, and it should be
 a problem!

-- 
Ticket URL: 
Django 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.57abcbd1f7a591d1f39b629f576b70b2%40djangoproject.com.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2016-08-01 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by basicdays):

 * cc: info@… (added)


--
Ticket URL: 
Django 
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/065.80b79680282af7e8c4e16a426a656826%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2016-04-05 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by charettes):

 FWIW I started to work on this issue (which is related to #24100 to
 #24067) on [https://github.com/django/django/compare/master...charettes
 :migration-signals-refactor a branch].

 The plan here is to make the `pre_migrate` signal dispatch it's plan
 (#24100) and inject `CreatePermision` operations after `CreateContentType`
 operations (that are injected after `CreateModel` operations just like
 `RenameContentType` operations are meant to be injected after
 `RenameModel` operations in order to solve #24067).

 I'll try to get this into 1.10.

--
Ticket URL: 
Django 
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/065.4178a00eb7ce71b0bf2b50fe23d1f665%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2016-04-05 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by theoden-dd):

 Replying to [comment:20 alanjds]:

 I've failed with Django 1.9, even after adapting emit_post_migrate_signal
 to its new signature:
 {{{
 db_alias = schema_editor.connection.alias
 try:
 # Django 1.9
 emit_post_migrate_signal(2, False, db_alias)
 except TypeError:
 # Django < 1.9
 try:
 # Django 1.8
 emit_post_migrate_signal(2, False, 'default', db_alias)
 except TypeError:  # Django < 1.8
 emit_post_migrate_signal([], 2, False, 'default', db_alias)
 }}}

 This led me to this most significant part of stack trace and error:
 {{{
 ...
   File "/local/lib/python2.7/site-
 packages/django/core/management/sql.py", line 50, in
 emit_post_migrate_signal
 using=db)
   File "/local/lib/python2.7/site-
 packages/django/dispatch/dispatcher.py", line 192, in send
 response = receiver(signal=self, sender=sender, **named)
   File "/olivia/local/lib/python2.7/site-
 packages/django/contrib/sites/management.py", line 20, in
 create_default_site
 if not Site.objects.using(using).exists():
 ...
 django.db.utils.OperationalError: no such table: django_site
 }}}

 Has anyone got the success with 1.9?

--
Ticket URL: 
Django 
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/065.e9f2180a3869781dfbf70ccc8809fa1b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2016-01-15 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by acidjunk):

 I can confirm that it also works for me.

 0001.py added custom permissions
 0002.py assigned custom permissions to a group

 Without the workaround by guettli in 0002.py: the custom permissions
 weren't available.

 Thanks

 R

--
Ticket URL: 
Django 
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/065.6fccc8c5c3121d8fbccc03032929ccd1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-12-03 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by cmichal):

 Replying to [comment:20 alanjds]:
 >
 > Is this acceptable instead of a ''wontfix'' ?

 way better. it works for me, thanks!

 one minor thing is that when you add group permission for the first time
 you need to pass it's id, for the second time Permission object is also
 good - strange...

 m

--
Ticket URL: 
Django 
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/065.1940e8e1c3c80110f9c4f9663b04a5b9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-10-04 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by blueyed):

 * cc: django@… (added)


--
Ticket URL: 
Django 
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/065.700c67a0b05bc6d5e543e26c21e5f152%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-09-24 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by alanjds):

 * cc: alan.justino@… (added)


--
Ticket URL: 
Django 
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/065.253999e21d9142b1db77becf3845811e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-09-24 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by alanjds):

 * needs_docs:  0 => 1


Comment:

 Replying to [comment:12 guettli]:
 > I am not happy with this issue being "wontfix".
 >
 > A helper method `create_missing_content_types_and_permissions()` would
 be nice.

 Found! This helper method exists already:
 `django.core.management.sql.emit_post_migrate_signal`

 {{{
 from django.core.management.sql import emit_post_migrate_signal

 def create_group(apps, schema_editor):
 db_alias = schema_editor.connection.alias
 try:
 emit_post_migrate_signal(2, False, 'default', db_alias)
 except TypeError:  # Django < 1.8
 emit_post_migrate_signal([], 2, False, 'default', db_alias)

 Group = apps.get_model('auth', 'Group')
 Permission = apps.get_model('auth', 'Permission')
 (...)
 }}}

 I suggest this behavior and "how to deal with" to be documented on the
 Permissions page.

 Is this acceptable instead of a ''wontfix'' ?

--
Ticket URL: 
Django 
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/065.4505e8d58a5181c3440846350783e7e5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-08-18 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by adehnert):

 * cc: adehnert (added)


--
Ticket URL: 
Django 
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/065.9b4505d6603a5bf9923ac157f04e39c5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-06-26 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by frnhr):

 The solution jwhitlock proposes with calling `create_permissions` from
 migration fixed one of my problematic migration, but not another. The
 other migration is calling `loaddata` command to do a one-time fixture
 import, and it was failing because required `ContentType` objects haven't
 been created. So it seems to be another face of the same problem.

 Here is a more dirty workaround until an official solution becomes
 available. I think it has better changes of fixing the problem in case
 solution with `create_permissions` fails:

 {{{
 if ContentType.objects.filter(**whats_needed_for_this_migration).count() <
 1:
 print("Running another migrate command from migration to create
 ContentType objects:")
 call_command('migrate', 'users', '0002')  # this should cite migration
 from the same app, just prior to this one
 print("Finished with the migrate command.")
 }}}

 I'm guessing the only thing really needed from the `migrate` management
 command in this situation is:

 {{{
 emit_post_migrate_signal(created_models, self.verbosity, self.interactive,
 connection.alias)
 }}}

 but not sure how to populate the arguments.

 I have no idea if using `call_command("migrate")` from a migration (of all
 places...) can be problematic, but in my particular case there don't seem
 to be any problems.

 The lengths we have to go to... Please **willfix** this.

--
Ticket URL: 
Django 
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/065.b290e33d3704cfa2f7269984ff4d0e65%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-06-26 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by frnhr):

 * cc: frnhr (added)


--
Ticket URL: 
Django 
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/065.4f1d7502246a0f68ac050dbcb9d4a1b8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-06-19 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by antialiasis):

 Chiming in with another +1 on the not-wontfixing - this is stopping me
 from running tests.

--
Ticket URL: 
Django 
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/065.6f43c913c975369b9a870ae18296f82e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-06-14 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by dmugtasimov):

 I am not happy with this issue being "wontfix", too.

--
Ticket URL: 
Django 
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/065.7269c0f9640703a1474bd87f2c26f70c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-06-04 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by TZanke):

 * cc: TZanke (added)


--
Ticket URL: 
Django 
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/065.2bd01fde923156119954878835b8fd57%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-06-04 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by guettli):

 * cc: hv@… (added)


--
Ticket URL: 
Django 
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/065.adad23dc83fcf47e7b1042a3254f1548%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-06-04 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by guettli):

 I am not happy with this issue being "wontfix".

 A helper method `create_missing_content_types_and_permissions()` would be
 nice.

--
Ticket URL: 
Django 
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/065.d6a46ecb5a3f4db0a4c85fa607561b09%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-05-29 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by scottwoodall):

 * cc: scott.woodall@… (added)


--
Ticket URL: 
Django 
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/065.1fd48203a7563149942dafb23c378173%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-03-28 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by MarkusH):

 You might want to keep an eye on #24100

--
Ticket URL: 
Django 
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/065.0f26ade6c380c4cea35c2b740fd0369d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-03-16 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by collinanderson):

 One thing we could do is have a `post_migration` signal that runs after
 _every_ migration. That way it's consistent.

--
Ticket URL: 
Django 
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/065.a413ce69d95ff806275876e39faa517c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-03-16 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by bronger):

 * cc: bronger@… (added)


--
Ticket URL: 
Django 
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/065.dc3f9b45d1c3e44d401504cb71030d08%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-03-16 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by bronger):

 South used to have `send_pending_create_signals()`.  A django equivalent
 would be useful.

--
Ticket URL: 
Django 
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/065.18acdf3a67af99674f0bb89cd6a62228%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2015-03-08 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by jwhitlock):

 Here's an example of calling `create_permissions` directly from a data
 migration, as suggested  by carljm:

 {{{
 def make_permissions(apps, schema_editor, with_create_permissions=True):
 Group = apps.get_model("auth", "Group")
 Permission = apps.get_model("auth", "Permission")
 try:
 perm = Permission.objects.get(
 codename='add_mymodel', content_type__app_label='my_app')
 except Permission.DoesNotExist:
 if with_create_permissions:
 # Manually run create_permissions
 from django.contrib.auth.management import create_permissions
 assert not getattr(apps, 'models_module', None)
 apps.models_module = True
 create_permissions(apps)
 apps.models_module = None
 return make_permissions(
 apps, schema_editor, with_create_permissions=False)
 else:
 raise
 my_new_group = Group.objects.create(name="test_group")
 my_new_group.permissions.add(perm)
 }}}

 Feels a little hacky, but it solved this `wontfix` for me .  I'd prefer a
 migration configuration that says "stop migrating, emit `post_migrate`
 signals, and restart migrations."

--
Ticket URL: 
Django 
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/065.94576d82e90dd87aa004f7e8f21b913b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2014-10-15 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by carljm):

 If using `ContentType.objects.get_for_model` is not possible, perhaps
 calling `django.contrib.auth.management.create_permissions(...)` in the
 migration would work?

--
Ticket URL: 
Django 
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/065.fde7ca17ddd0057ee1e41b4c3755198d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2014-10-09 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by coagulant):

 I figure out ContentType.objects.get_for_model won't work "as is" in
 datamigration, because only default model managers are available.

--
Ticket URL: 
Django 
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/065.4e6f701bd1342aed430b374a46bbe9ce%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2014-10-07 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--

Comment (by Nicals):

 I understand the won't fix, but a way to solve this group permissions
 problem would be appreciated. I'm blocked on a project by this...

--
Ticket URL: 
Django 
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/065.67e7d2a575d402275e1ec035da02a8fb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2014-09-05 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:  wontfix
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by andrewgodwin):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 This is a limitation of the signalling system we use to create
 ContentTypes; if we fixed this to work, there would then be issues where
 the ContentTypes were created too early.

 I would suggest that the data migration uses
 ContentType.objects.get_for_model to get the ContentType before making the
 Permission, as this creates the ContentType if necessary and has internal
 caching too.

--
Ticket URL: 
Django 
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/065.8e63c4aced498ab2e7284b7b4e065397%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23422: Cannot add Permission to Group in data migration

2014-09-05 Thread Django
#23422: Cannot add Permission to Group in data migration
+--
 Reporter:  tjwalch |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by chriscauley):

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


Comment:

 I'm a bit new to the migrations system, but I was able to verify this. I
 created a new app called "my_app" and a model called "MyModel". I created
 the first migration and then the following data migration:


 {{{
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals

 from django.db import models, migrations

 def make_permissions(apps,schema_editor):
 Group = apps.get_model("auth","Group")
 Permission = apps.get_model("auth","Permission")
 my_new_group = Group(name="test_group")
 my_new_group.save()
 my_new_group.permissions.add(
 Permission.objects.get(codename='add_mymodel',content_type__app_label='my_app')
 )

 class Migration(migrations.Migration):

 dependencies = [
 ('my_app', '0001_initial'),
 ('auth', '0001_initial'),
 ]

 operations = [
 migrations.RunPython(make_permissions,reverse_code=lambda
 *args,**kwargs: True)
 ]
 }}}

 If I run these separately (`python manage.py migrate my_app 0001;python
 manage.py migrate my_app 0002`), everything is cool. Together it breaks
 (`python manage.py migrate my_app`). You could solve this yourself by
 doing a get_or_create on the content type and on the permission, but that
 is by no means an adequate solution.

--
Ticket URL: 
Django 
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/065.be9bfefe2e0f5d486bc69d2ebdce3081%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #23422: Cannot add Permission to Group in data migration

2014-09-05 Thread Django
#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: 
Django 
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/050.80538ebe2616da85d6c4003ff48b2a7d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.