简体   繁体   中英

Generate a Django form from an array

I am looking for a way to generate a Django form based on a Python data structure such as an Array or a List of an un-specfied size or contents.

For example if the array contained ['Name', 'Question 1', 'Question 2'] a Django form with fields 'Name' 'Question 1' 'Question 2' would be generated. If array contained ['Question 20'] a Django form with field 'Question 20' would be generated.

I have looked through Django form factory, but I have not found a generator that works off an Array rather than a Django model.

I am a beginner with Django and Python so am not sure of any way to approach this problem.

List cannot provide enough details about forms fields. Store forms as json : https://github.com/WiserTogether/django-remote-forms

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM