How to change default value for a field in an InlinePanel in the Wagtail admin

47 Views Asked by At

We have a membership app that includes the following class definitions (shown in part):

class Member(models.Model):
    ...


class Membership(models.Model):
    member = ParentalKey('Member', null=True, blank=True, related_name='memberships', on_delete=models.CASCADE)
    date_effective = models.DateField(null=True, blank=True)
    date_expires = models.DateField(null=True, blank=True)
    is_paid = models.BooleanField(default=True)
    ...

    panels = [
        FieldRowPanel([
            FieldPanel('membership_type'),
            FieldPanel('is_paid'),
            FieldPanel('date_effective'),
            FieldPanel('date_expires', read_only=True),
        ])
    ]            

date_expires is calculated and so is set to read_only in the FieldPanel definition. That is causing it to show as "None". I would like it to say 'TBD' (to be determined). Also, is_paid is set up to default to "True", but when a membership is entered in the Wagtail admin, then we need the default value for is_paid to be "False". I have looked through both the Wagtail docs and the Wagtail code, but I cannot find anything like get_formset that is available for inlines in the Django admin. In the Wagtail admin, is it possible to set the default value of date_expires to 'TBD' and the default value of is_paid to "False"?

enter image description here

0

There are 0 best solutions below