Skip to content

dynamic textarea filled with API response on load #9

@lsmith77

Description

@lsmith77

I am building a "rule editor" for NLP purposes. I want to give editors the ability to see "in real time" (after saving), how their rule would work in practice for training sentences they have added to the rule.

ie. a Rule admin form, contains a one2many inline TrainingSentence form

I am hoping to use your package to add a dynamic textarea field "response" that is populated on load with the JSON response from the NLP system for each sentence.

But I am unsure how to construct the DynamicField so that it reads the data from the rule property so that I can call my get_json() helper function to fetch the JSON to set as the initial value for the response dynamic field.

class TrainingSentence(models.Model):
    rule = models.ForeignKey(Rule, on_delete=models.CASCADE)

class TrainingSentenceForm(DynamicFormMixin, forms.ModelForm):
    response = DynamicField(..)

Any advice would be greatly appreciated.

Note: Eventually I might just do this via AJAX, but I am hoping to stick to just backend logic for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions