I have created a model as:
class Job(models.Model):
jobId = models.AutoField(primary_key = True)
startTime = models.DateTimeField(auto_now_add = True)
When I'm doing
print(model_to_dict(job))
I'm getting only
{'jobId': 1}
as output. Why 'startTime' filed is not coming in the output? Please help me with this issue.
A: model_to_dict
is only outputting editable fields.
B: startTime
is not set editable because of the auto_now_add
.
So I guess you end up with one of the methods from this question.