python - Django admin.py readonly_fields not working -


i need show on django administration date object created, date field should disabled of modification.

here model on models.py

from django.db import models django.utils import timezone  class mymodel(models.model):     name = models.charfield(max_length=200)     date_of_creation = models.datefield(default=timezone.now) 

here admin.py

from django.contrib import admin .models import mymodel  class mymodeladmin(admin.modeladmin):     readonly_fields = ('date_of_creation',)  admin.site.register(mymodel) 

the "save() override set date of creation" isn't case here.

i tried this snippet , django documentation already, can't find mistake.

please note i'm beginner in django, , first app.

thank in advance.

you need register admin class model.

admin.site.register(mymodel, mymodeladmin) 

Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -