3👍
✅
You can mark the field as read-only but still have it visible in the admin, or completely exclude it.
class MyModel(models.Model):
field1 = models.CharField(max_length=20) # this is editable
field2 = models.CharField(max_length=20, editable=False) # this is not
or
@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
exclude = ['field2']
If you’re using a custom model form in the admin, just don’t include the field in the fields
attribute.
0👍
As far as I remember there are a lot of ways to do this, with the fields attribute on Meta
you can hide or select which fields to show.
check This example
- [Django]-Can I include partial view in Web2Py, passing specific variables into it?
- [Django]-Why my celery task is not running?
- [Django]-Partial Update option is not visible in the browsable api window
- [Django]-Getting SSL error when sending email via Django
Source:stackexchange.com