3π
β
Why not do
baseSet = ThreadedComment.objects.filter(tree_path__contains = ('%010i' % int(baseT.comment_ptr_id)))
so that the search string for id=1 will be β0000000001β and wonβt be a substring of β0000000011β?
EDIT: As per the comment below, it might be better to use COMMENT_PATH_DIGITS. This is a little messier because youβre using formatting to set a formatting tag. It looks like this:
tree_path__contains = ('%%0%ii' % COMMENT_PATH_DIGITS % int(baseT.comment_ptr_id))
π€Paul Eastlund
2π
the regexp would be '(^|/)0*%d(/|$)' % baseT.comment_ptr_id
and you use it with tree_path__regex
read about MPTT for alternatives to this approach.
π€Samus_
- [Django]-GeoDjango serialize GeoJSON skipping 'id' field
- [Django]-SSL error while running syncdb on Django with PostgreSQL
Source:stackexchange.com