Redirect to a new form in Django Admin on Save

Hi I am creating a trouble ticket app for my company, and I want to redirect the user to a new form where he will specify the diagnose and solution he offered. my admin is Basically, Right now my code is calling the first form, when the obj created is new or the status is open and it is calling the ClosedForm when my status is closed.

What I want is that, when the user changes the status from Open to Closed and saves the ticekt, he is redirected to ClosedForm


class TicketFormClosed(ModelForm):
    class Meta:
        model = Ticket
        fields = ('status','call_sheet_number','diagnose','solution','call_attend_date',)

class TicketForm(ModelForm):
    class Meta:
        model = Ticket
        exclude = ('call_sheet_number','diagnose','solution','call_attend_date',)

class TicketAdmin(admin.ModelAdmin):

    def get_form(self, request, obj=None, **kwargs):
        form = super(TicketAdmin, self).get_form(request, obj, **kwargs)
        if obj == None or obj.status=='Open':
            form = TicketForm   
            form = TicketFormClosed
        return form


Take a look at the source code for admin.ModelAdmin. You will find the overridable hooks for redirecting there.

for example, search for HttpResponseRedirect in django/contrib/admin/ and you'll see the default flow playing out.

Need Your Help

Where do I put my XML beans in a Spring Boot application?

xml spring spring-boot configuration-files

I'm getting back into Spring (currently v4). It's all wonderful now with @SpringBootApplication and the other annotations but all the documentation seems to forget to mention how I define other bea...