mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Fixed #18168 -- clarified precedence of validation
any choices set by formfield_for_choice_field are still subject to model validation of the model field's choices attribute
This commit is contained in:
		| @@ -1389,6 +1389,15 @@ templates used by the :class:`ModelAdmin` views: | |||||||
|                         kwargs['choices'] += (('ready', 'Ready for deployment'),) |                         kwargs['choices'] += (('ready', 'Ready for deployment'),) | ||||||
|                 return super(MyModelAdmin, self).formfield_for_choice_field(db_field, request, **kwargs) |                 return super(MyModelAdmin, self).formfield_for_choice_field(db_field, request, **kwargs) | ||||||
|  |  | ||||||
|  |     .. admonition:: Note | ||||||
|  |  | ||||||
|  |         Any ``choices`` attribute set on the formfield will limited to the form | ||||||
|  |         field only. If the corresponding field on the model has choices set, | ||||||
|  |         the choices provided to the form must be a valid subset of those | ||||||
|  |         choices, otherwise the form submission will fail with | ||||||
|  |         a :exc:`~django.core.exceptions.ValidationError` when the model itself | ||||||
|  |         is validated before saving. | ||||||
|  |  | ||||||
| .. method:: ModelAdmin.get_changelist(self, request, **kwargs) | .. method:: ModelAdmin.get_changelist(self, request, **kwargs) | ||||||
|  |  | ||||||
|     Returns the ``Changelist`` class to be used for listing. By default, |     Returns the ``Changelist`` class to be used for listing. By default, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user