﻿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	nobody	"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.

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	new	Database layer (models, ORM)	4.2	Normal				Unreviewed	0	0	0	0	0	0
