Guest User

Untitled

a guest
Jan 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. Error: Database test_myapp couldn't be flushed. Possible reasons:
  2. * The database isn't running or isn't configured correctly.
  3. * At least one of the expected database tables doesn't exist.
  4. * The SQL was invalid.
  5. Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
  6. The full error: column "id" of relation "threadedcomments_comment" does not exist
  7.  
  8. ...
  9. SELECT setval(pg_get_serial_sequence('"threadedcomments_comment"','id'), 1, false);
  10. ...
  11.  
  12. class ThreadedComment(Comment):
  13. title = models.TextField(_('Title'), blank=True)
  14. parent = models.ForeignKey('self', null=True, blank=True, default=None,
  15. related_name='children', verbose_name=_('Parent'))
  16. last_child = models.ForeignKey('self', null=True, blank=True,
  17. verbose_name=_('Last child'))
  18. tree_path = models.TextField(_('Tree path'), editable=False,
  19. db_index=True)
  20. #id = models.IntegerField()
  21.  
  22. objects = CommentManager()
  23.  
  24. def _get_depth(self):
  25. return len(self.tree_path.split(PATH_SEPARATOR))
  26. depth = property(_get_depth)
  27.  
  28. def _root_id(self):
  29. return int(self.tree_path.split(PATH_SEPARATOR)[0])
  30. root_id = property(_root_id)
  31.  
  32. def _root_path(self):
  33. return ThreadedComment.objects.filter(pk__in=self.tree_path.
  34. split(PATH_SEPARATOR)[:-1])
  35. root_path = property(_root_path)
  36.  
  37. def save(self, *args, **kwargs):
  38. skip_tree_path = kwargs.pop('skip_tree_path', False)
  39. super(ThreadedComment, self).save(*args, **kwargs)
  40. if skip_tree_path:
  41. return None
  42.  
  43. tree_path = unicode(self.pk).zfill(PATH_DIGITS)
  44. if self.parent:
  45. tree_path = PATH_SEPARATOR.join((self.parent.tree_path, tree_path))
  46.  
  47. self.parent.last_child = self
  48. ThreadedComment.objects.filter(pk=self.parent_id).update(
  49. last_child=self)
  50.  
  51. self.tree_path = tree_path
  52. ThreadedComment.objects.filter(pk=self.pk).update(
  53. tree_path=self.tree_path)
  54.  
  55. class Meta(object):
  56. ordering = ('tree_path',)
  57. db_table = 'threadedcomments_comment'
  58. verbose_name = _('Threaded comment')
  59. verbose_name_plural = _('Threaded comments')
  60.  
  61. CREATE TABLE threadedcomments_comment (
  62. comment_ptr_id integer NOT NULL,
  63. title text NOT NULL,
  64. parent_id integer,
  65. last_child_id integer,
  66. tree_path text NOT NULL
  67. );
Add Comment
Please, Sign In to add comment