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

4
  • You need to explain what you want to do. What do you mean by "dynamically"? What is dynamic here? Commented Jun 16, 2017 at 8:03
  • updated with an example. thanks @DanielRoseman Commented Jun 16, 2017 at 8: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. Commented Jun 16, 2017 at 8: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? Commented Jun 16, 2017 at 8:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.