Клонирование форм django с RichTextUploadingField с помощью javascript

Мои forms.description и forms.condition оба не редактируются, оба используют ckeditor RichTextUploadingField, до клонирования исходный редактируется .

models.py:

class Teststep(models.Model):
    testcase = models.ForeignKey(TestCasetest , null=True , on_delete= models.CASCADE)
    number = models.CharField(max_length=100 , null = True , blank = True)
    description = models.TextField(blank=True, null=True)
    condition = RichTextUploadingField(config_name="default",blank=True,null=True)
    remark = RichTextUploadingField(config_name="default",blank=True,null=True)
    modify_history = models.TextField(blank=True, null=True)
    def __str__(self):
        print(self.testcase.name,type(self.testcase.name))
        name  = self.testcase.name+'-('+str(self.number)+')'
        return name

forms.py

class Teststepform(forms.ModelForm):
    class Meta:
        model = Teststep
        fields = ['description','condition','remark','modify_history']

шаблоны

<div class="form-group">
{{teststepform.media}}
<table class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th>{% trans "number" %}</th>
            <th>{% trans "description" %}</th>
            <th>{% trans "condition" %}</th>
            <th>{% trans "remark" %}</th>
            <th>{% trans "modfiy_history" %}</th>            
        </tr>
    </thead>
    <tbody id="formset-teststep">
        <tr id="teststepform-list" class="">
            <td id="number"></td>
            <td id="description">{{teststepform.description}}</td>
            <td id="condition">{{teststepform.condition}}</td>
            <td id="remark">{{teststepform.remark}}</td>
            <td id="modify_history">{{teststepform.modify_history}}</td>
        </tr>
    </tbody>
</table>
</div>
<div class="form-group">
<div class="col-md-1 col-lg-1">
    <button type="submit" name="save" value="save" class="btn btn-success btn-lg">{% trans "Save" %}</button>
</div>
</div>

Это мой javascript для клонирования <tr id="formset-teststep">

// teststep button
var add_teststepform = document.getElementById('add_teststepform')
add_teststepform.addEventListener('click',AddTeststep)
function AddTeststep(event){
    event.preventDefault()
    const teststep_body = document.getElementById('formset-teststep')
    var teststep_tr_list = document.getElementById('teststepform-list').cloneNode(true)
    var total_lenth = (document.getElementsByClassName('grident-form-teststep')).length

    teststep_tr_list.setAttribute('class','grident-form-teststep')
    teststep_tr_list.setAttribute('id','id_teststep_show_'+total_lenth.toString())
    teststep_body.append(teststep_tr_list)
}

Я только изучаю javascript, чтобы сделать свой сайт динамичным

Вернуться на верх