You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure when or why this happens, but sometimes after saving a comment (not a reply to another comment) the annotate_tree filter isn't working, but the comment itself was saved successfully:
File "threadedcomments/models.py", line 16, in _get_depth
if self.tree_path.split is not None:
AttributeError: 'NoneType' object has no attribute 'split'
A quick workaround saves me from this:
diff --git a/threadedcomments/models.py b/threadedcomments/models.py
index 61c8587..7c45e0f 100644
--- a/threadedcomments/models.py
+++ b/threadedcomments/models.py
@@ -13,11 +13,14 @@ class ThreadedComment(Comment):
tree_path = models.TextField(null=True, blank=True, db_index=True)
def _get_depth(self):
- return len(self.tree_path.split(PATH_SEPARATOR))
+ if self.tree_path is not None:
+ return len(self.tree_path.split(PATH_SEPARATOR))
+ return 1
depth = property(_get_depth)
def _root_id(self):
- return self.tree_path.split(PATH_SEPARATOR)[0]
+ if self.tree_path is not None:
+ return self.tree_path.split(PATH_SEPARATOR)[0]
root_id = property(_root_id)
def save(self, *args, **kwargs):
The text was updated successfully, but these errors were encountered:
I changed the field not to be nullable so this error shouldn't happen again. Another matter entirely is, however, how it came to be that the tree_path wasn't constucted on the comment's save()
I'm not sure when or why this happens, but sometimes after saving a comment (not a reply to another comment) the annotate_tree filter isn't working, but the comment itself was saved successfully:
A quick workaround saves me from this:
The text was updated successfully, but these errors were encountered: