Django meta permissions -


i adding custom permissions via use of 'meta' in django models. see below simple example.

models.py

class meta:     permissions = (         ("can_do_stuff", "can stuff"),     ) 

this works great, add above code model , make migrations , migrate them. permission gets created , available use.

however, when remove (or modify) permission 'meta' section of model , again makemigrations, migrate permission (that removed/modified) not removed django system.

this wouldn't problem if had figured out permissions system 100% have been fine tuning things learn , result permissions list gets messy 'legacy' permissions.

i developing , releasing new versions production use on frequent basis, , permissions getting messy in production can't wipe db in dev.

is there recommended way of doing this?

i delete legacy permissions manually directly database (it seems 1 entry need delete , seems not cause problems). seems bad way of doing it, subject error, being forgotten etc.

have tried migrating backward instead of forward?

<app_label> <migrationname>: brings database schema state named migration applied, no later migrations in same app applied. may involve unapplying migrations if have migrated past named migration. use name 0 unapply migrations app.

my guess makemigrations command scans model's permissions meta, , produce 'insert' sql in permission table each missing permssion, doesn't two-way synchronization in migration script.

but migration script can revert changes 'delete' statement every 'insert'.

so try:

python manage.py migrate the_app the_migration_before_the_last 

if doesn't work either, submit bug django project.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -