Ticket #211 (assigned enhancement)
South do not track new and removed permissions
| Reported by: | janusz.harkot@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | commands | Version: | 0.6-pre |
| Keywords: | Cc: |
Description
Custom permissions can be added by specifying a permission tuple in models's Meta class.
Adding a permission during a development is a one of the elemements that shall be tracked by south.
Attachments
Change History
comment:1 Changed 4 years ago by andrew
- Status changed from new to assigned
- Version set to Mercurial tip
- Milestone set to 0.6
comment:3 Changed 4 years ago by ben.davis@…
This seems like more of a bug (maybe needs to be a different ticket, not sure), as south breaks current functionality -- ie, once an app has migrations, syncdb can no longer see it in order to add permissions for its model.
I suppose a workaround is to create a manual migration...
comment:4 Changed 4 years ago by andrew
Yeah, that's the current way. The alternative is to use the --all option to syncdb, which makes it look at all apps again.
comment:5 follow-up: ↓ 6 Changed 4 years ago by south@…
I can't get the --all switch to work with syncdb nor do I find it documented anywhere in Django. Can someone give an example of how this is supposed to work?
comment:6 in reply to: ↑ 5 Changed 4 years ago by andrew
Replying to south@…:
I can't get the --all switch to work with syncdb nor do I find it documented anywhere in Django. Can someone give an example of how this is supposed to work?
It's a custom extension to the South syncdb version; if it's not working, you might not have South enabled properly.
comment:9 Changed 3 years ago by diegobz
For the record with 0.7.1 I could add new permissions to an existing model.
On 0.7.0 it didn't work.
comment:10 Changed 3 years ago by andrew
Yes, but it only tracks added permissions, and the fix itself seems to occasionally break people's code (it's currently commented out in trunk).
This won't be fixed till both those issues are resolved :)
comment:11 Changed 3 years ago by Mike <stodge@…>
Any update on this? This is a deal breaker for us - any suggestions how to fix it? Is there a workaround? Thanks
comment:12 Changed 3 years ago by andrew
You'll have to just create the permissions manually in a migration - load the model from contrib.auth.models, and create them. I've not had enough time or resources to look into this properly yet; there are more pressing issues that need solving first...
(for reference, we did have some code that "implemented" this, but it turns out to randomly crash some people's installs)
comment:14 Changed 3 years ago by Laurie
Just want to add my voice to those who say they need this. I know that doesn't fix anything, sorry, but this is something I consider to be a bug, and dearly need for my projects.
comment:15 Changed 3 years ago by me@…
+1 for this one.
I recently bumped into this one. The only way to get the new permission added, was to disable South, run manage.py syncdb, then re-enable South again.
comment:16 Changed 3 years ago by anonymous
No, syncdb --all indeed works for us. (This doesn't imply that we wouldn't appreciate seeing this issue resolved.)
comment:17 Changed 3 years ago by amjoconn@…
I also ran into this. It is most unexpected that syncdb doesn't work wrt permissions the way it does without south.
comment:18 Changed 2 years ago by slinkp@…
Note also that you'll have to get_or_create ContentType? instances in your migrations too, in order to add a permission, because ContentTypes? aren't created until a signal is sent after the first time all migrations are run.
comment:19 Changed 2 years ago by mr.c.d
+1
comment:20 Changed 2 years ago by daniel
+1
comment:21 Changed 2 years ago by Sam Bull <osirius@…>
+1
comment:22 Changed 23 months ago by guettli
I use this pattern to create permissions in a datamigration:
Stackoverflow: Adding new custom permissions in Django
comment:23 follow-up: ↓ 30 Changed 15 months ago by philipe.rp@…
+1
I did a workaround using post_migrate signal: http://devwithpassion.com/felipe/south-django-permissions/
comment:24 Changed 13 months ago by chrisma
+1, philipe's "workaround using post_migrate signal" works like a charm though.
comment:25 Changed 12 months ago by mark0978@…
For south to truly replace syncdb, it should behave the way syncdb does. I think the right fix for this (and another issue we bumped into) is to send the post_syncdb signal on all models just like syncdb does. If that were done, this problem would be solved.
comment:26 Changed 12 months ago by andrew
South does send post_syncdb, and always has, it just sends it at the end of the migration run for compatability reasons. This bug is not really to do with being more like syncdb in that regard.
comment:27 Changed 8 months ago by bigbobah
+1
comment:28 Changed 7 months ago by sander
+1
comment:29 Changed 6 months ago by rmatt
For me also an important feature ! The syncdb -all is really not an option on production DBs !
comment:30 in reply to: ↑ 23 Changed 3 months ago by anonymous
Replying to philipe.rp@…:
+1
I did a workaround using post_migrate signal: http://devwithpassion.com/felipe/south-django-permissions/
Philipe's solution seems to work well.

Interesting idea, and probably necessary, since syncdb is responsible for creating them in the first place. I'll schedule it for inclusion in this or the next release.