当使用基于方法的视图时,使用reverse
重定向没有对此抱怨,并且仍然可以找到根url conf.但是,在基于班级的观点中,它抱怨:
ImproperlyConfigured at /blog/new-post/
The included urlconf 'blog.urls' does not appear to have any
patterns in it. If you see valid patterns in the file then the
issue is probably caused by a circular import.
我的类定义如下:
class BlogCreateView(generic.CreateView):
form_class = Blog
template_name = 'blog/new-post.html'
success_url = reverse('blog:list-post')
如何在基于类的视图中正确使用reverse
for success_url
?谢谢.
PS:,我感兴趣的是为什么在这个错误之后需要重新启动runserver
(不像TemplateDoesNotExists
那样的错误,它不需要重新启动runserver
)