Django Class-based Views with Multiple Forms -


by default django’s class-based views support single form per view.

i need more forms per view because want combine foreignkey relations various modelform instances , appear in formmodel.

in django documentation , other tutorials found formsets, in default examples repeat same form multiple times, not need.

inline formsets looks need , didn't found example gcbv createview. can give me examples, link tutorial ?


for example:

class product(models.model):  name = models.charfield(max_length=200,db_index=true) 

class productimage(models.model):  # foreign key product = models.foreignkey('products.product', on_delete=models.cascade)  image = models.imagefield(upload_to=upload_to) 

class productcreateview(createview): model = product form_class = productmodelform success_url = '../' 

class productmodelform(forms.modelform):  class meta:     model = product 

in template want appear in same form product form fields, image field, can repeated multiple times(click button add new image)

name field description field upload image field   - add new image link/button submit 

thanks.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -