> Would the following strategy work? delete all app permission and use, create_permissions to recreate them
Yes, but that will delete all the user and group permissions as well; you'll have to reassign them. > How do I know to which db table a given permission points? Or does it point to a model? They point to models through the Permission.content_type foreign key; ContentType have an (app_label, model_name) unique tuple. Best, Simon Le lundi 18 mars 2019 04:35:55 UTC-4, Yevgeny Bar Lev a écrit : > > Thanks Simon! > Two questions: > a) Would the following strategy work? delete all app permission and use, > create_permissions to recreate them > b) How do I know to which db table a given permission points? Or does it > point to a model? > > On Mon, Mar 18, 2019 at 6:38 AM Simon Charette <chare...@gmail.com > <javascript:>> wrote: > >> Hello Yevgeny, >> >> I'd start by deleting your stale content types[0] which your permissions >> are attached >> to. That should deal with deleted model case. >> >> For the renames I suggest you drop into a shell and manually edit the >> Permission.name >> of the misnamed instances. >> >> Best, >> Simon >> >> [0] >> https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-contrib-contenttypes >> >> Le dimanche 17 mars 2019 15:52:45 UTC-4, Yevgeny Bar Lev a écrit : >>> >>> Thanks Simon. Is there some nonmagical solution? I mean, is it possible >>> to fix some of the permissions manually without breaking stuff? >>> >>> On Sun, Mar 17, 2019, 9:21 PM Simon Charette <chare...@gmail.com> wrote: >>> >>>> Hello Yevgeny, >>>> >>>> I don't have magic solution to suggest to you given the current state >>>> of your >>>> permission data after a few iterations but I just wanted to let you >>>> know that >>>> it's a known issue[0] and a contributor is actively working on getting >>>> it fixed[1]. >>>> >>>> Cheers, >>>> Simon >>>> >>>> [0] https://code.djangoproject.com/ticket/29843 >>>> [1] https://github.com/django/django/pull/10540 >>>> >>>> Le dimanche 17 mars 2019 13:31:16 UTC-4, Yevgeny Bar Lev a écrit : >>>>> >>>>> Hello, >>>>> I have noticed that the available permissions list, which can be set >>>>> to users/groups in the admin doesn't match my models. This happened after >>>>> a >>>>> few standard migrations, where some models were renamed, some deleted, >>>>> and >>>>> new models were added. The list is basically not updated, and represents >>>>> a >>>>> mixed state of the db, before and after the above migrations. >>>>> >>>>> manage.py inspectdb show the CORRECT state of the database. >>>>> >>>>> I have tried to follow the following solution, which basically didn't >>>>> do much. >>>>> >>>>> from django.contrib.auth.management import create_permissionsfrom >>>>> django.apps import apps >>>>> >>>>> create_permissions(apps.get_app_config('my_app_name')) >>>>> >>>>> I will appreciate your help. >>>>> Best, >>>>> Yevgeny. >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to django-users...@googlegroups.com. >>>> To post to this group, send email to django...@googlegroups.com. >>>> Visit this group at https://groups.google.com/group/django-users. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/9c49dff1-c6b1-43e6-818d-f56ab761558d%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/django-users/9c49dff1-c6b1-43e6-818d-f56ab761558d%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com <javascript:>. >> To post to this group, send email to django...@googlegroups.com >> <javascript:>. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/7f88aa1a-4d3f-4611-9611-c733b81909a6%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/7f88aa1a-4d3f-4611-9611-c733b81909a6%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1042f212-68ed-4f3c-b82d-58a50989bb0f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.