﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34539	`get_prep_value` no longer called for JSONField	Julie Rymer	Julie Rymer	"Hello, I just upgraded from django 4.1 to 4.2 and I have a custom `JSONField` with a  `get_prep_value()` override that stopped working. After searching a bit, I saw that was because `JSONField.get_prep_value()` is no longer called in 4.2 ([https://github.com/django/django/commit/5c23d9f0c32f166c81ecb6f3f01d5077a6084318 5c23d9f0c32f166c81ecb6f3f01d5077a6084318]).

I think this issue need a resolution either:

- `JSONField` should call `get_prep_value()` like all other fields type, because this is the method that the [https://docs.djangoproject.com/en/4.2/ref/models/fields/#django.db.models.Field documentation] tell us to override in custom fields.
  Otherwise we need to override `get_db_prep_value()` which is heavier and does not have the same purpose. I think simply replacing `connection.ops.adapt_json_value(value, self.encoder)` with `connection.ops.adapt_json_value(self.get_prep_value(value), self.encoder)` in `JSONField.get_db_prep_value()` would fix this

- If there is a good reason to no longer call `get_prep_value()`, this exception for `JSONField` should be clearly documented in [https://docs.djangoproject.com/en/4.2/ref/models/fields/#django.db.models.Field.get_prep_value custom get_prep_value() doc]. It should also be added to [https://docs.djangoproject.com/en/4.2/releases/4.2/#backwards-incompatible-changes-in-4-2 Backwards incompatible changes in 4.2 release note] because I got stuck with this issue with no warning when migrating.

PS: #34397 seems to be related but in fact is about Django 3.2 so it is not the current issue"	Bug	closed	Database layer (models, ORM)	4.2	Release blocker	fixed		Simon Charette Florian Apolloner Tim Graham	Ready for checkin	1	0	0	0	0	0
