3
3
3ds2011-08-03 17:27:02
Django
3ds, 2011-08-03 17:27:02

Django: instead of foreign key - select another field from table in queryset?

The question is the following:

def ajax(request, client_id):<br/>
 client = get_object_or_404(Client, pk=client_id)<br/>
 works = Work.objects.values('short_description', 'thumb', 'content', 'real_size', 'type').filter(client=client)<br/>

in the 3rd line, all the works of this client are selected. type is a foreign key for the work_type table that has an id and a slug. I don’t catch up with something at the end of the day, how to make a selection so that instead of type (numbers of the id-shnik) the value of slug ('text', 'video', 'image') from the table is substituted. (select_related - will not work).
only option to write .query("full sql code")?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ano, 2011-08-03
@3ds

'type__slug' won't work either? :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question