AndrewIngram/django-extra-views

Edit 'error_messages' in 'CreateWithInLinesView'

eudaldt opened this issue · 2 comments

Is there a way to edit a field message error using CreateWithInLinesView? In a ModelForm I used to do this:

class FormulariCaptura(ModelForm):
    name = forms.CharField(error_messages={'unique': 'There's an entry withe the same name'}
    class Meta:
        model = CaptureVersion
        fields = ("name", "int_reference_number", "capture_version_id_provider", "associated_register", "start_date", 
        "end_date", "target_size", "probe_size", "sections", "responsibles",)

Yes, you can set the form_class attribute on the InlineFormsetFactory instance, e.g.:

from extra_views import CreateWithInLinesView, InlineFormsetFactory


class MyView(CreateWithInLinesView):
    ...
    model = Capture  # I guess
    inlines = [CaptureVersionInline]
    

class CaptureVersionInline(InlineFormsetFactory):
    model = CaptureVersion
    form_class = FormulariCaptura

Perfect, thanks!