2👍
Just had this issue
When using auto_now_add=True
or editable=False
in the field definition, the admin will not show the corresponding fields unless you specify them in the readonly_fields
of the admin form definition.
if in models.py
class TransmissionLog(models.Model):
dataSource = models.ForeignKey(Browser, editable=False)
dateCreated = models.DateTimeField(auto_now_add=True, editable=False)
then admin.py needs
class TransmissionAdminManager(admin.ModelAdmin):
readonly_fields = ['dataSource', 'dateCreated']
admin.site.register(TransmissionLog, TransmissionAdminManager)
Source:stackexchange.com