Is it possible to render different templates in a CreatView?

In my app, a user can report a problem about specific items.
Such as a user reporting a problem about a certain mechanical unit not working.
This is done using a CreateView. If the user has already created the initial problem, I want to be able to render a different template using that same view/url pattern. I want this instead of another type of view so that the URL stays the same and also because the user and an admin can send messages back and forth so when a user sends a new message, it will just be using the CreateView.
I have looked into rendering a different template via the GET method but have not had any luck.
Is this possible to do?

Yes, see get_template_names.

When trying to find a way to hook into the Django generic CBVs, I always point people to Classy Class-Based Views and CBV diagrams. It’s worth spending time on these sites to become aware of how you can alter the default behaviors of those views.

Note - you’re likely going to want to render different forms for this as well. See get_form_class to handle changes for that.

2 Likes