﻿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
36847	FileField(upload_to=...) callback no longer sees `auto_now_add ` field	Ran Benita	Nilesh Pahari	"In Django 5.2 and before, accessing an `auto_add_now=True` DateTimeField in the `upload_to` callback of a `FileField` was possible, i.e. the field was filled with the current time. In Django 6.0, the field value is now `None` (the field is not `null=True`).

It is not a big problem for me, since I just dropped the usage of `auto_add_now` (I try to avoid it in new code anyway). But perhaps is can be helpful to document in the changelog.

The [https://docs.djangoproject.com/en/6.0/ref/models/fields/#django.db.models.FileField.upload_to documentation of `upload_to`] currently states that the PK is not available, maybe it can mention `auto_add_now` and friends as well.

{{{#!python
from django.db import models

def upload_to_callback(instance, filename):
    return str(instance.created.year) # <- Crash, obj.created is None

class MyModel(models.Model):
    created = models.DateTimeField(
        auto_now_add=True,
    )
    file = models.FileField(
        max_length=9999,
        upload_to=upload_to_callback,
    )
}}}
"	Bug	closed	Database layer (models, ORM)	6.0	Release blocker	fixed	upload_to, auto_now_add, pre_save	Simon Charette	Ready for checkin	1	0	0	0	0	0
