Returns iterable of objects that contain data. For example, resolves Django ManyToMany relationship so the attributes of the related models can then be accessed.
(cls, current_objects)
| 166 | |
| 167 | @classmethod |
| 168 | def get_iterable_objects(cls, current_objects): |
| 169 | """ |
| 170 | Returns iterable of objects that contain data. For example, resolves Django ManyToMany relationship |
| 171 | so the attributes of the related models can then be accessed. |
| 172 | """ |
| 173 | if current_objects is None: |
| 174 | return [] |
| 175 | |
| 176 | if hasattr(current_objects, "all"): |
| 177 | # i.e, Django ManyToMany relationships |
| 178 | if ismethod(current_objects.all): |
| 179 | return current_objects.all() |
| 180 | return [] |
| 181 | |
| 182 | elif not hasattr(current_objects, "__iter__"): |
| 183 | current_objects = [current_objects] |
| 184 | |
| 185 | return current_objects |
| 186 | |
| 187 | def prepare_template(self, obj): |
| 188 | """ |