Forms

SelfHandlingModelForm

forms.py

from horizon_contrib.forms import SelfHandlingModelForm

class IssueCreateForm(SelfHandlingModelForm):

    class Meta:
        model = Issue
        fields = ['project', 'priority', 'description', 'due_date']
        widgets = {
            'description': Textarea,
            'due_date': DateTimeWidget(attrs={'id': "due_date"}, options=settings.DATE_PAST_OPTIONS)
        }

    # handle it or leave blank or call super where is implemented basic logic for saving models
    # but in many cases is not sufficient and we must override this
    def handle(self, request, data, model_class):

        model_instance = model_class.objects.get(id=data.pop("object_id"))

views.py

from horizon_contrib.forms import ModalFormView

class CreateView(ModalFormView):

    form_class = IssueCreateForm
    success_url = "horizon:redmine:..."

    template_name = 'redmine/issue/create.html'

or simple use our CreateView which is based on SelfHandlingForm but use Django ModelForm

here we can specified fields array which be used for modelform factory or our form_class.

CreateView

from horizon_contrib.forms import CreateView

class CreateView(CreateView):

    name = _('Create Whatever') # your "action" name

    form_class = None # your form
    template_name = 'horizon_contrib/forms/create.html' # your template

    success_url = ...

UpdateView

Nothing special here. This view is same as CreateView, but tries getting initial data