-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Name of order field in migrations #60
Comments
Yes, that might be bug. True, I've never tested for this case. I would suggest adding the
I would be interested in your tests and if the approach I suggest here is working well for your case. |
I add migrations.AddField(
model_name='attribute',
name='settings',
field=sortedm2m.fields.SortedManyToManyField(related_name='sce', to='scenario.Setting', sort_value_field_name='order'),
preserve_default=False,
), Maybe because Django migration create object for migrate with default parameters. But I see next code in https://github.com/django/django/blob/master/django%2Fdb%2Fmigrations%2Foperations%2Ffields.py#L43: def state_forwards(self, app_label, state):
# If preserve default is off, don't use the default for future state
if not self.preserve_default:
field = self.field.clone()
field.default = NOT_PROVIDED
else:
field = self.field
... Error in django? |
Hm, not sure. I'm not sure were the problem might be currently. However that's not really one of my priorities so far. Would you be willing to find the cause of the issue and try to fix it? I'm happy to review any pull requests and assist with questions about sortedm2m internals. |
Unfortunately, I closed this project, but bug is so strange... I try to create pull request during next month. |
I checked on Django 1.8 and all fine! In migration: migrations.AddField(
model_name='book',
name='authors',
field=sortedm2m.fields.SortedManyToManyField(help_text=None, to='m2m.Author', sort_value_field_name=b'order'),
), And after applied it in db created table with field 'order'. I`m sorry for bad issue :( |
Cool, glad that it worked out! |
Problem IMHO in migrations of Django 1.7 (not South). I use custom field name for order field in M2M:
then make migration and apply it. After which in db was created M2M table with default field name ('sort_value') instead my overriding name ('order').
The text was updated successfully, but these errors were encountered: