Skip to content
Advertisement

Concatenating into a new field in a Django query

Consider a table called DataTable. It has two fields, A and B. I want to return all rows of this table plus annotate a field called C that is a concatenation of A and B.

Here is what I have tried

JavaScript

problem here is that C is literally just the string literal “A – B” for every returned row. I want to use the actual values of A and B into that concatenation.

Advertisement

Answer

looks like you need concat:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement