0

I am using Django CreateView without a custom template. There are a few fields that are not required for my form. So in my model, blank is set to true. So validation is fine. However, I want to visually indicate to the user which fields are required or not, before the try to submit.

Adding an asterisk in the verbose name seems silly because that carries over to admin view and the placeholders.

class MainForm(models.Model):
    name = models.CharField(max_length=255)
    address = models.CharField(max_length=255)
    summary = models.CharField(max_length=63, verbose_name='Brief Description')
    volume = models.IntegerField(blank=True)
    frequency = models.ForeignKey(Frequency, blank=True)
    ...

class RequestForm(forms.ModelForm):
    ...
    class Meta:
        model = models.Request
        fields = ['company_name', 'mailing_address', 'summary',
                  'owner_area', 'business_case', 'data_classification',
                  'data_volume', 'frequency', 'requested_on_behalf_of']
    ...

I would really like the standard red asterisk, but anything will do really. Without creating a custom template. Is this possible?

Hailee
  • 288
  • 1
  • 4
  • 13
  • 2
    Maybe this will help https://stackoverflow.com/questions/1254046/how-to-render-form-field-with-information-that-it-is-required – cwhisperer Apr 24 '19 at 13:27
  • I might have to go that route. Just hoped there was something build into the createview as to not have to create a template. – Hailee Apr 24 '19 at 14:53

0 Answers0