I have a blog section of my website and I made an CommentUpdateView and after submiting the form it gives me this error
ModuleNotFoundError at /blog/post/comment/update/18/
No module named 'test-post-ecomon'
but I don't undersant why because this post exists and I implemented get_absolute_url in my Contact models and It should work right? When I create a new commment it works.
view
class CommentUpdateView(LoginRequiredMixin, UpdateView):
model = Comment
form_class = CommentUpdateForm
template_name = 'blog/update_comment.html'
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
def get_queryset(self, *args, **kwargs):
return super().get_queryset(*args, **kwargs).filter(author=self.request.user)
model
class Comment(models.Model):
author = models.ForeignKey(User, on_delete=models.CASCADE)
post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments')
reply = models.ForeignKey('self', on_delete=models.CASCADE, null=True, related_name='replies')
content = models.TextField(_('Content'))
posted_date = models.DateTimeField(_('Posted Date/Time'), auto_now_add=True)
updated_date = models.DateTimeField(_('Updated Date/Time'), auto_now=True)
def __str__(self):
return f'{self.author.username} - {self.post.title}'
def get_absolute_url(self):
return reverse('post', self.post.slug)
urls
path('post/<slug:slug>/', PostDetailView.as_view(), name='post'),
path('post/comment/update/<int:pk>/', CommentUpdateView.as_view(), name='update-comment'),
question from:
https://stackoverflow.com/questions/65861351/modulenotfounderror-at-blog-post-comment-update-18-no-module-named-test-post 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…