Week 10 is 8.8-8.14.
I started working on 8.10.
What did you do this week?
First, I thought about the next steps. Currently, the functions to be completed are list style, list cloning, and applying modification. The next task is to export the list configuration to the JSON file and import the JSON file migration configuration. In these steps, the applying modification has the highest priority. Only after the applying modification function is completed, I can realize list cloning and more modification and management.
So I first worked on the applying modification part. I finished this part very quickly. The test uses 5 lists. After the form is submitted by clicking the submit button on the page, all data will be returned to the back end. The value returned by request.POST is a list corresponding to the key. The list stores the value of five lists. I used the loop method and applied all the changes.
At this time, there is a problem. Only one radio button can be selected from the data in one column and only one data is returned. This has always been a problem. I found the cause of the problem in form = form _ class (initial = initial_data,mlist = m_list, auto_id = True) to generate a form. In fact, it is rendered into HTML code according to the class of the form and the initial data. However, the IDs generated automatically by these codes in the process of generating the list are all from 0. This results in the same id for all fields. I spent four days looking for a solution to this problem.
1. I try to generate all the forms directly. This problem can be solved without using the loop function. So I tried to merge the initial data of all the lists and use the form = form _ class function generates a form. But I failed. This function can't recognize a dictionary with a list value, and finally only displays a list.
2. I found a way to customize the id. By defining the attr of the widget and adding the id, can generate a customized id. First, I modified the id, but the situation has not changed. All radio buttons have the same customize id. I try to change the id to str (list_id) + field_ name to generate a unique id. I tried to customize functions, initialize classes, and modify variables across files, but none of them can achieve the function I want to complete. I guess it's because of the list_ form.py is a static model file, which cannot be modified dynamically.
3. I try to find a way to realize this function in the templae language. But I didn't find it. All the functions are used to display data and cannot be modified.
After nearly five days of exploration, up to now, 8.15, I have two ideas to complete this function.
Idea 1: replace the radio button with a drop-down menu. In the whole table, only the radio button part has a problem. The pull-down menu that can also realize the selection function can be used normally. Radio buttons with only two options can also be changed into drop-down menus to realize functions.
Idea 2: rewrite the HTML page. Because the form function is used to automatically render the HTML code, it is difficult for me to modify the id. At the same time, this problem also appears in other parts, but there is a problem with the use of radio buttons. However, in consideration of the need to implement clone list, change list style, export list, import content and other functions, this problem may affect the implementation of subsequent functions and take more time. There are many functions to be implemented on this page, so I prefer to write HTML pages directly for generating tables.
What is coming up next?
Rewrite the table in the template file using HTML language.
Practice of creating checkboxes and lists.
Realize batch modification.
Realize the function of clone list.