-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid ContentType after running "migrate" command #7
Comments
Thanks for the info and a bug-report link. |
Does this http://stackoverflow.com/a/13952198/2987806 solution suit? |
@zlorf any update on this issue? I'm gonna need to migrate to something else |
@vahidm it's safe to just ignore that warnings |
@vahidm No update so far, but this message (warning) is only annoying, not harmful. |
I know +1s aren't exactly helpful, but for what it's worth… I'd love a fix for this. I took a look myself and noped out of there pretty quickly; it doesn't seem like an obvious change would solve it. |
I also run into this since a while. It took my attention when I run 'migrate.py migrate' in my Jenkins deployment script. Unfortunately the deployment stuck at this point. A workaround is to use 'migrate.py migrate --no-input'. But this solution only skips that warning and don't solve the issue. The general issue ist that permissions from django.auth are bound to models. But in dbsettings you want to bind the permission to an app. The only model you may bind the permission to is the dbsetting.models.Settings. So maybe you could change the dbsettings.management.mk_permissions: ct, created = ContentType.objects.get_or_create(model='', app_label=appname,
defaults={'name': appname}) to ct, created = ContentType.objects.get_or_create(model='settings',
app_label='dbsettings') (I don't know what 'name' is good for. I remember some changes in Django that this field was removed) and if are_global_settings:
permission = (
'can_edit__settings',
'Can edit %s non-model settings' % app_label,
) to if are_global_settings:
permission = (
'can_edit_%s_settings' % app_label,
'Can edit %s non-model settings' % app_label,
) After a look at my database I found a lot of can_edit__settings with different description strings:
Is this a bug? Should the name of the permission be like in my proposal above? I can't see how this could work. The disadvantage of this approach is, that you may have some 'stale' permissions. Some thoughts about this: 1.) Ignore this issue. Django does the same on removed permissions in the code. :) If you want I can have a look at the implementation and create a PR. Unfortunately this change may break a lot of application that use the permissions. Any thoughts? |
No bug here, I need to rethink the permissions here, and I like the idea of binding app-level permissions to Settings model instead of non-existing model of an app. |
Ok. That's good. So I missed something. I think the Settings model is the only suitable model. I was thinking about models from django (e.g. django.auth.models.Permission). But this somehow hurts my feelings. :-) |
When using django 1.7 migrations i get the following message:
core - is my app where i use django-dbsettings.
I found this closed ticket in django bugtracker: https://code.djangoproject.com/ticket/23519
Here is code which creates content-type with empty model: https://github.com/zlorf/django-dbsettings/blob/master/dbsettings/management.py#L13
To fix this we need to tell django "we need this model, so don't touch this" or find another way to implement app-level permissions.
The text was updated successfully, but these errors were encountered: