Files
app-store-optimization/skills/loki-mode/benchmarks/results/2026-01-05-10-37-54/swebench-loki-patches/django__django-13933.patch

31 lines
1.3 KiB
Diff

# django__django-13933
# Loki Mode Multi-Agent Patch
# Attempts: 1
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -1246,8 +1246,8 @@ class ModelChoiceField(ChoiceField):
# This class is a subclass of ChoiceField for purity, but it doesn't
# actually use any of ChoiceField's implementation.
default_error_messages = {
- 'invalid_choice': _('Select a valid choice. That choice is not one of'
- ' the available choices.'),
+ 'invalid_choice': _('Select a valid choice. %(value)s is not one of'
+ ' the available choices.'),
}
iterator = ModelChoiceIterator
@@ -1315,7 +1315,10 @@ class ModelChoiceField(ChoiceField):
value = getattr(value, key)
try:
self.queryset.get(**{key: value})
- except (ValueError, TypeError, self.queryset.model.DoesNotExist):
- raise ValidationError(self.error_messages['invalid_choice'], code='invalid_choice')
+ except (ValueError, TypeError, self.queryset.model.DoesNotExist):
+ raise ValidationError(
+ self.error_messages['invalid_choice'],
+ code='invalid_choice',
+ params={'value': value},
+ )
def has_changed(self, initial, data):