<!-- language: lang-default -->
class Seo(models.Model):
title = models.CharField( max_length=500, blank=True)
description = models.CharField(max_length=500, blank=True)
keywords = models.CharField(max_length=1000, blank=True)
url = models.CharField(max_length=500, blank=True)
static = models.BooleanField()
class SeoInlines(generic.GenericStackedInline):
model = Seo
form = SeoForm
extra = 1
max_num = 1
I need to make Seo.url not editable (editable=False or SeoInlines.exclude = ('url', ) or SeoInlines.readonly_fields = ('url',)) when seo.static = 1.
How can I do this?
You’ve already said it:
Then what you can do is override your form definition if static = 1. I’m assuming the problem only comes in for record updates not initial saves. You can check out how to do this dynamically over here