0
class Concat(Aggregate):
    # supports COUNT(distinct field)
    function = 'GROUP_CONCAT'
    template = '%(function)s(%(distinct)s%(expressions)s)'

    def __init__(self, expression, distinct=False, **extra):
        super(Concat, self).__init__(
            expression,
            distinct='DISTINCT ' if distinct else '',
            output_field=CharField(),
            **extra)

I have come across a splendid answer in Stackoverflow which provided a Django solution to simulate MySQL's GROUP_CONCAT. And now I am wondering how to set a delimiter for it in Django. I tried many possible options, among them '%(function)s(%(distinct)s% ", "(expressions)s)', but none of my attemps were successful. Any ideas ?

Community
  • 1
  • 1
Edgar Navasardyan
  • 4,261
  • 8
  • 58
  • 121

0 Answers0