0

Using Django 1.10, Python 3.5,

I have stored various information about the columns and tables I want to use to extract data in another table called smart_view

That smart_view has the following columns:

  1. id (auto increment)
  2. name (varchar 255)
  3. columns (jsonb type)
  4. tables (jsonb type)
  5. conditions (jsonb type)

I want to dynamically select data columns from tables that may vary depending on the data stored in smart_view table

I read about dynamically generate filters using an answer from https://stackoverflow.com/a/4720109/80353.

Is that applicable to my situation and how do I do the same for the tables (or Model) part?

UPDATE

The usual way of selecting specific values is

Entry.objects.values_list('id', 'headline')

As seen in https://docs.djangoproject.com/en/1.11/ref/models/querysets/#values-list

By dynamic, I meant you wouldn't know beforehand which model to extract the values from and which values they might be because they are stored as data in the table called smart_view

Kim Stacks
  • 10,202
  • 35
  • 151
  • 282
  • You need to explain what you want to do. What do you mean by "dynamically"? What is dynamic here? – Daniel Roseman Jun 16 '17 at 08:03
  • updated with an example. thanks @DanielRoseman – Kim Stacks Jun 16 '17 at 08:08
  • That isn't really an example. What do you want to output? And note that that is **not** the usual way of creating a queryset; that is the way of creating a values list, which is a very restricted usage of queries with extremely limited usefulness. – Daniel Roseman Jun 16 '17 at 08:09
  • Okay I have rephrased my question. Nothing to do with queryset directly. Have I sufficiently made this question clearer about what I am looking for? – Kim Stacks Jun 16 '17 at 08:13

0 Answers0