diff --git a/adminsortable/templates/adminsortable/shared/nested_objects.html b/adminsortable/templates/adminsortable/shared/nested_objects.html
index c979302..7b4f36a 100644
--- a/adminsortable/templates/adminsortable/shared/nested_objects.html
+++ b/adminsortable/templates/adminsortable/shared/nested_objects.html
@@ -3,22 +3,25 @@
{% if regrouped_objects %}
{% for regrouped_object in regrouped_objects %}
- -
- {% with object=regrouped_object.grouper %}
- {% if sortable_by_class_is_sortable %}
- {% render_object_rep object %}
- {% else %}
- {{ object }}
- {% endif %}
- {% endwith %}
- {% if regrouped_object.list %}
- {% with regrouped_object_list_length=regrouped_object.list|length %}
-
1 %}class="sortable"{% endif %}>
- {% render_list_items regrouped_object.list %}
-
- {% endwith %}
+ {% with object=regrouped_object.grouper %}
+ {% if object %}
+ -
+ {% if sortable_by_class_is_sortable %}
+ {% render_object_rep object %}
+ {% else %}
+ {{ object }}
+ {% endif %}
+
+ {% if regrouped_object.list %}
+ {% with regrouped_object_list_length=regrouped_object.list|length %}
+
1 %}class="sortable"{% endif %}>
+ {% render_list_items regrouped_object.list %}
+
+ {% endwith %}
+ {% endif %}
+
{% endif %}
-
+ {% endwith %}
{% endfor %}
{% endif %}