You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I'm encountering this weird issue where the model's date field with auto_now_add field wont show up in page props, I'm guessing it's some thing to do with the InertiaJson Encoder as I'm new to this I dont know where to start to fix this.
Thank You
classDailyReport(models.Model):
date=models.DateField(auto_now_add=True)
issues_challenges=models.TextField(
blank=True, null=True, help_text="Describe any challenges or blockers"
)
additional_notes=models.TextField(
blank=True, null=True, help_text="Any relevant updates or comments"
)
def__str__(self):
returnf"Report by on {self.date}"@propertydefget_date(self):
returnself.date
Under the hood the InertiaJsonEncoder uses Django's model_to_dict function and unfortunately this is an implementation detail of that function. model_to_dict doesn't include any fields that have editable=False and any fields with auto_now_add=True automatically set editable=False.
The best bet here is to convert this model to a dict or json before sending it to inertia.
If you have any ideas of how this could work more fluidly, let me know because I also think this is annoying behavior 😄
Hi I'm encountering this weird issue where the model's date field with auto_now_add field wont show up in page props, I'm guessing it's some thing to do with the InertiaJson Encoder as I'm new to this I dont know where to start to fix this.
Thank You
The text was updated successfully, but these errors were encountered: