Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a key-value model in datatables #115

Open
fbzyx opened this issue Jun 15, 2023 · 0 comments
Open

Display a key-value model in datatables #115

fbzyx opened this issue Jun 15, 2023 · 0 comments

Comments

@fbzyx
Copy link

fbzyx commented Jun 15, 2023

First of all thank you for the great project :)

I have a model where i store a key and a value like this:

class DataModel(models.Model):
    key = models.CharField(max_length=128)
    value = models.CharField(max_length=128)

The value in key is the name that i want to use as header or column name (in column defs) and the field value is the field that i want to display in the table.

So the table should look like this:

|key1|key2|key3|key4|
|value1|value2|value3|value4|
|value1|value2|value3|value4|
. . . .
. . . .

How could i implement something like this? where should i start? Is there an example i can see?

In all the examples and implementations I have done before I always have to put the field name in column_defs. What I want now is to do it dynamically, since I don't know what value the field "key" will have..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant