code: def q_mentioned_fields(q, model):
      
      query = Query(model)
      where = query._add_q(q, used_aliases=set(), allow_joins=False)[0]
      return list(sorted(set(expression_mentioned_fields(where))))
docs: Returns list of field names mentioned in Q object.
  
      Q(a__isnull=True, b=F('c')) -> ['a', 'b', 'c']