Created
March 27, 2017 21:17
-
-
Save MandarGogate/32c4d087d6ff478ff69cfa04b14a7ade to your computer and use it in GitHub Desktop.
Django Form Wizard With Model Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Form1( ModelForm ): | |
class Meta: | |
model = AModel | |
fields = ( 'fieldA', ) | |
class Form2( ModelForm ): | |
class Meta: | |
model = AModel | |
fields = ( 'fieldB', ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AModel( Model ): | |
fieldA = CharField() | |
fieldB = CharField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AWizard( SessionWizardView ): | |
instance = None | |
def get_form_instance( self, step ): | |
if self.instance is None: | |
self.instance = AModel() | |
return self.instance | |
def done( self, form_list, **kwargs ): | |
self.instance.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment