问题
django.core.exceptions.ImproperlyConfigured: The included URLconf ‘xsite.urls’ does not appear to have any patterns in it.
File "C:\Programs\Miniconda3\envs\djg2env\lib\site-packages\django\urls\base.py", line 58, in reverse
app_list = resolver.app_dict[ns]
File "C:\Programs\Miniconda3\envs\djg2env\lib\site-packages\django\urls\resolvers.py", line 513, in app_dict
self._populate()
File "C:\Programs\Miniconda3\envs\djg2env\lib\site-packages\django\urls\resolvers.py", line 447, in _populate
for url_pattern in reversed(self.url_patterns):
File "C:\Programs\Miniconda3\envs\djg2env\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Programs\Miniconda3\envs\djg2env\lib\site-packages\django\urls\resolvers.py", line 593, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 'xsite.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.
Django 高级实战编程
Django高级实战 开发企业级问答网站
项目结合:需求分析/Django高级用法/算法/设计模式/TestCase测试/云计算服务
Django开发企业实战 面向就业/升职(中高级教程)
视频教程分享地址:
https://study.163.com/course/introduction/1209407824.htm?share=2&shareId=400000000535031
出错代码
class ArticleUpdateView(LoginRequiredMixin, UpdateView):
model = Article
form_class = ArticleForm
context_object_name = 'form'
template_name = 'aiblogs/article_update_form.html'
success_url = reverse('blogs:article-list')
def get_context_data(self, *args, **kwargs):
context = super(ArticleUpdateView, self).get_context_data(*args, **kwargs)
context['albums'] = Album.objects.filter(blog=self.request.user.myblog).order_by('indx')
return context
不出错代码
class ArticleUpdateView(LoginRequiredMixin, UpdateView):
model = Article
form_class = ArticleForm
context_object_name = 'form'
template_name = 'aiblogs/article_update_form.html'
# success_url = reverse('blogs:article-list')
def get_context_data(self, *args, **kwargs):
context = super(ArticleUpdateView, self).get_context_data(*args, **kwargs)
context['albums'] = Album.objects.filter(blog=self.request.user.myblog).order_by('indx')
return context
def get_success_url(self):
return reverse('blogs:article-list')