Re: How to get names of columns from QuerySet without executing it

2020-07-08 Thread Dvil Djé
For a light version of the query, you can try a qs.first() as Django will limit the SQL request to the first element. On Saturday, July 4, 2020 at 10:11:41 PM UTC+2, Eugene Kulak wrote: > > How to get names of columns from QuerySet without executing it? > If it is not possible w

Re: How to get names of columns from QuerySet without executing it

2020-07-06 Thread Eugene Kulak
el._meta.fields] > > Regards, Michael > > > Am 04.07.2020 um 22:11 schrieb Eugene Kulak: > > How to get names of columns from QuerySet without executing it? > > If it is not possible what would be the most easier way to execute a > > lighter version of the q

Re: How to get names of columns from QuerySet without executing it

2020-07-05 Thread Michael Fladischer
What about introspecting the model associated with the QuerySet: qs = SomeModel.objects.all() columns = [f.column for f in qs.model._meta.fields] Regards, Michael Am 04.07.2020 um 22:11 schrieb Eugene Kulak: How to get names of columns from QuerySet without executing

Re: How to get names of columns from QuerySet without executing it

2020-07-04 Thread Eugene Kulak
The closes I can get with this is the following: comp = queryset.query.get_compiler(DEFAULT_DB_ALIAS) fields = [alias or sql.split('.')[1] for _, (sql, _), alias in comp.get_select()[0]] On Saturday, July 4, 2020 at 4:11:41 PM UTC-4, Eugene Kulak wrote: > > How to get names of column

Re: How to get names of columns from QuerySet without executing it

2020-07-04 Thread Eugene Kulak
, Jul 5, 2020 at 10:12 AM Eugene Kulak > > wrote: >> >>> How to get names of columns from QuerySet without executing it? >>> If it is not possible what would be the most easier way to execute a >>> lighter version of the query. >>> The quer

Re: How to get names of columns from QuerySet without executing it

2020-07-04 Thread Eugene Kulak
he column you want]) > > On Sun, Jul 5, 2020 at 10:12 AM Eugene Kulak > wrote: > >> How to get names of columns from QuerySet without executing it? >> If it is not possible what would be the most easier way to execute a >> lighter version of the query. >> The

Re: How to get names of columns from QuerySet without executing it

2020-07-04 Thread Vishesh Mangla
he column you want by using > [name of model].objects.get(filter=[name of the column you want]) > > On Sun, Jul 5, 2020 at 10:12 AM Eugene Kulak > wrote: > >> How to get names of columns from QuerySet without executing it? >> If it is not possible what would be the mos

Re: How to get names of columns from QuerySet without executing it

2020-07-04 Thread Akinfolarin Stephen
you can filter out the column you want by using [name of model].objects.get(filter=[name of the column you want]) On Sun, Jul 5, 2020 at 10:12 AM Eugene Kulak wrote: > How to get names of columns from QuerySet without executing it? > If it is not possible what would be the most easi

How to get names of columns from QuerySet without executing it

2020-07-04 Thread Eugene Kulak
How to get names of columns from QuerySet without executing it? If it is not possible what would be the most easier way to execute a lighter version of the query. The query itself is unknown, it could be anything. -- You received this message because you are subscribed to the Google Groups