Ticket #211 (assigned enhancement)

Opened 5 years ago

Last modified 6 months ago

South does 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

michigan.png (142.9 KB) - added by Will Jannings 8 months ago.
Source: http://ultrasoundtechnicianexpert.com
Phlebotomy.jpg (2.4 KB) - added by Will Jannings 8 months ago.
Source: http://phlebotomyguide.com
X ray Tech.jpg (6.8 KB) - added by anonymous 8 months ago.
Source: http://xraytechnicianguide.org

Change History

comment:1 Changed 5 years ago by andrew

  • Status changed from new to assigned
  • Version set to Mercurial tip
  • Milestone set to 0.6

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.

comment:2 Changed 5 years ago by andrew

  • Milestone changed from 0.6 to 0.7

Bumping to 0.7.

comment:3 Changed 5 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 5 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 5 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 5 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:7 Changed 5 years ago by andrew

  • Milestone changed from 0.7 to 0.7.1

comment:8 Changed 4 years ago by andrew

  • Milestone changed from 0.7.1 to 0.7.2

comment:9 Changed 4 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 4 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 4 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 4 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:13 Changed 4 years ago by andrew

  • Milestone changed from 0.7.2 to 1.0

comment:14 Changed 4 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 4 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 4 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 4 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 4 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 4 years ago by mr.c.d

+1

comment:20 Changed 4 years ago by daniel

+1

comment:21 Changed 3 years ago by Sam Bull <osirius@…>

+1

comment:22 Changed 3 years ago by guettli

I use this pattern to create permissions in a datamigration:
Stackoverflow: Adding new custom permissions in Django

Last edited 3 years ago by guettli (previous) (diff)

comment:23 follow-ups: ↓ 30 ↓ 37 Changed 3 years ago by philipe.rp@…

+1

I did a workaround using post_migrate signal: http://devwithpassion.com/felipe/south-django-permissions/

comment:24 Changed 2 years ago by chrisma

+1, philipe's "workaround using post_migrate signal" works like a charm though.

comment:25 Changed 2 years 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 2 years 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 2 years ago by bigbobah

+1

comment:28 Changed 2 years ago by sander

+1

comment:29 Changed 2 years 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 21 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.

comment:31 Changed 15 months ago by j.arnds@…

+1

comment:32 Changed 15 months ago by koorgoo@…

+1 Useful feature.

comment:33 Changed 15 months ago by anonymous

Could someone fix the grammar on this one?

"South does not" instead of "South do not", every time I get an email because of a +1 I go thru this momentary thought that someone is saying it should not.

It would probably be best to change the title to

"South Should"

The use of shall in the body doesn't bother me nearly as much because it doesn't show up in the subject of the emails that are sent.

comment:34 Changed 15 months ago by guettli

  • Summary changed from South do not track new and removed permissions to South does not track new and removed permissions

comment:35 Changed 15 months ago by anonymous

+1
Doing manage.py syncdb --all in production doesn't feel right.

comment:36 Changed 14 months ago by naktinis@…

+1

comment:37 in reply to: ↑ 23 Changed 14 months ago by anonymous

+1

Replying to philipe.rp@…:

+1

I did a workaround using post_migrate signal: http://devwithpassion.com/felipe/south-django-permissions/

Thanks Philipe, this appears to work pretty well. Based on how simple your solution is, I'm actually really surprised that South itself hasn't been patched for this issue yet...

comment:38 Changed 10 months ago by tapia@…

+1

Changed 8 months ago by Will Jannings

Changed 8 months ago by Will Jannings

Changed 8 months ago by anonymous

comment:39 Changed 6 months ago by anonymous

Philipé's trick works! +11

Note: See TracTickets for help on using tickets.