Answer the question
In order to leave comments, you need to log in
How to redirect to the same page in Django 2?
The models are written:
class Article(models.Model):
#....
def get_absolute_url(self):
return reverse('detail', kwargs={'id': self.id})
class ArticleCreateView(View):
def post(self, request):
bound_form = ArticleForm(request.POST)
if bound_form.is_valid():
new_article = bound_form.save()
return redirect(new_article) # ЗДЕСЬ ОШИБКА
return render(request, 'blogapp/article_create.html', {'form': bound_form})
Answer the question
In order to leave comments, you need to log in
Most likely, there is no named parameter id in the pattern, so NoReverseMatch. Try passing in reverse args or setting a named parameter in a pattern.
Wang, that in your urls.py the group is named crooked or the name is crooked, or it doesn’t exist at all
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question