-
Notifications
You must be signed in to change notification settings - Fork 16
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 default value for match_field #28
Comments
Not sure I understand the issue. |
I think it would be more clear if the default value will be "id", cause every model has field "id" from the stock, and doesn't have field "pk". Or pk field name should be got through "_meta.pk.attname" method or replaced with "_get_pk_val" |
I was under the impression it would be otherwise actually. The default primary key is usually “id” but “pk” would always translate to the actual one (even if primary key was manually set on another model) I’ll add a test for this and update accordingly |
It works only with model attribute "pk"
works as you expect, but for get_field that doesn't work:
|
Get exception FieldDoesNotExist when match_field is not specified.
match_field='pk'
match_field = (match_field,) if isinstance(match_field, str) else match_field
_match_fields = [self.model._meta.get_field(name) for name in match_field]
Easy way to reproduce
from django.contrib.auth import get_user_model
User = get_user_model()
User._meta.get_field("pk")
django.core.exceptions.FieldDoesNotExist: User has no field named 'pk'
Django==3.2.8
django-bulk-update-or-create==0.3.0
The text was updated successfully, but these errors were encountered: