Search code examples
djangoformview

Switch case for form_class and template_name


I have a session var with the name 'foo'. Now I would like, depending of the value of 'foo' load a specific form and template in my cbv. So I need to put form_class and template_name into a switch case.

Which function is the right place for this? get? get_form? looks like nothing is really the right place for this.

Anyone a suggestion or knows another way? :)


Solution

  • CBV explorer is your friend: http://ccbv.co.uk/projects/Django/1.5/django.views.generic.edit/CreateView/

    You need to override

    def get_form_class(self):
    

    and

    def get_template_names(self):