AttendanceSession.date_modified never updates after creation
π Looking for an issue? Welcome! This issue is open for contribution. If this is the first time youβre requesting an issue, please:
- Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that donβt follow the guidelines wonβt be answered.
- Confirm that youβve read the guidelines in your comment.
Observed behavior
AttendanceSession exposes date_modified through the API, but nothing ever updates it. The field is declared with a creation-time default and no auto-update (kolibri/core/attendance/models.py:45-46):
date_created = DateTimeTzField(default=local_now, editable=False)
date_modified = DateTimeTzField(default=local_now)
It is never assigned anywhere else β the only other references in the module are the migration, the serializer's field list, and a not-None assertion in test/test_models.py:39. The serializer also marks it read-only, so a client cannot set it either (kolibri/core/attendance/viewsets/attendance_session.py:62):
read_only_fields = ("created_by", "date_created", "date_modified")
and AttendanceSessionSerializer.update only writes validated_data, which cannot contain it.
So date_modified is fixed at creation and reports the creation time forever, no matter how many times the session's attendance is edited afterwards.
Other "modified"/"updated" timestamps in the codebase are kept current, either with auto_now or by explicit assignment:
kolibri/core/device/models.py:629βupdated_at = models.DateTimeField(auto_now=True)kolibri/core/device/models.py:517βupdated = models.DateTimeField(auto_now=True)kolibri/core/discovery/models.py:102βlast_accessed = models.DateTimeField(auto_now=True)kolibri/core/content/utils/channel_import.py:996βchannel.last_updated = local_now()
AttendanceSession.date_modified is neither. (Job.time_updated in kolibri/core/tasks/models.py:32 is also never written, but it is not exposed through an API serializer.)
Errors and logs
No error β the write succeeds and returns 200, the value simply does not move. Driving the real API as a coach:
created : date_created=2026-10-25 00:12:59.158269+05:30 date_modified=2026-10-25 00:12:59.158277+05:30
PATCH status=200 attendance record present flipped False -> True
after : date_modified=2026-10-25 00:12:59.158277+05:30
date_modified CHANGED = False
Expected behavior
Editing a session β including flipping a learner's present flag through the nested attendance_records write path β should move date_modified forward, so the field means what its name says.
User-facing consequences
Anything that reads date_modified to answer "when was this attendance last changed?" gets the creation time instead. Today that is mostly latent: I could not find a frontend consumer of the field, so this is low severity right now. It matters because the field is already part of the serialized API surface, so the wrong value is what any future consumer β a "last edited" column in a coach report, or an audit/export β would be built on, and because a stale value is harder to notice than a missing one.
A note on where the fix belongs
The obvious fix, auto_now=True on the model, looks wrong here. Morango deserialization saves through the same path (app_model.save(update_dirty_bit_to=False) in morango/sync/operations.py:454), so an auto_now field would be rewritten with the receiving device's clock on every sync, diverging from the value the authoring device sent. Setting it in AttendanceSessionSerializer.update instead confines the change to genuine API edits and leaves synced-in values intact β which also matches how channel.last_updated is handled, the other DateTimeTzField of this kind in the tree.
Steps to reproduce
As a coach of the classroom, create a session and then edit it:
r = self.client.post(
"/api/attendance/attendancesession/",
{"collection": classroom.id,
"attendance_records": [{"user": learner.id, "present": False}]},
format="json",
)
sid = r.data["id"]
before = AttendanceSession.objects.get(id=sid)
time.sleep(1.1)
self.client.patch(
f"/api/attendance/attendancesession/{sid}/",
{"attendance_records": [{"user": learner.id, "present": True}]},
format="json",
)
after = AttendanceSession.objects.get(id=sid)
assert after.date_modified != before.date_modified # fails on develop
Result on develop: the PATCH returns 200 and the record's present really does flip to True, but date_modified is byte-for-byte what it was at creation.
Context
Affects develop. kolibri/core/attendance/ is the newest module in the tree. Separate from #15666, which is about AttendanceRecord's dataset invariant in the same module. Low severity β filing it because it is a small, contained correctness gap in a field that is already published through the API.
AI usage
Claude Code (on my instruction to keep scanning the newer code) noticed date_modified had no auto-update while reading the attendance models for an unrelated issue, and I asked it to confirm before anything was written up. It checked that the field is never assigned anywhere in the module, then drove the real API as a logged-in coach to show the value unchanged after a successful PATCH that did modify the attendance. It also surveyed how every other modified/updated timestamp in the tree is maintained, which is what establishes this as inconsistent rather than intentional, and checked morango's deserialization save path to work out that auto_now would be the wrong remedy. I reviewed the survey of the other timestamp fields, the reasoning about where the fix belongs, and the reproduction's result on current develop before filing, and I am deliberately flagging this as low severity rather than dressing it up.
@rtibblesbot please validate this issue.
Verdict: claim holds
Evidence: kolibri/core/attendance/models.py:45 and kolibri/core/attendance/viewsets/attendance_session.py:62,79-90 on develop at 44a4e68aac
date_modified = DateTimeTzField(default=local_now)has noauto_now.- The serializer marks it read-only, and
update()writes onlyvalidated_dataplusAttendanceRecord.update_or_create. Nothing setsdate_modified. AbstractFacilityDataModelhas no save hook that touches modified timestamps.- No existing issue reports this. #15666 covers a different invariant in the same module.
Two supporting statements in the issue were wrong, and I've corrected them:
kolibri/core/attendance/test/test_models.py:39also references the field, but only to assert it is notNone.Job.time_updated(kolibri/core/tasks/models.py:32) is never written either, sodate_modifiedis not the only timestamp of this kind that never updates.
Changes
- Observed behavior, "only other references": added
test/test_models.py:39. The list omitted that reference. - "Every other β¦ timestamp is kept current" β "Other β¦":
Job.time_updated(kolibri/core/tasks/models.py:32) is never written. - "is the only one that is neither" β "is neither", plus a note on
Job.time_updated. The original sentence was false.
Written by rtibblesbot, an LLM-based coding agent.
@rtibbles do i need to directly open the pull request without asking for assign
Hi! π
Thanks so much for your interest! This issue is already assigned. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.
We really appreciate your willingness to help. π
Are you preparing for Google Summer of Code? See our GSoC guidelines.
8. @rtibbles do i need to directly open the pull request without asking for assign
Hi @gitseraj, I'm already working on the fix for this issue, and it has been assigned to me. Thanks! π
Note that while all the issues you have opened are valid, we do deliberately limit the number of help wanted issues to ensure we are able to review contributor PRs in a timely fashion. In future, please be mindful of opening PRs before you have been assigned to an issue by our team.