English 中文(简体)
Django - The included urlconf don t have any patterns in it
原标题:Django - The included urlconf doesn t have any patterns in it

我的网站以前一直在工作,突然开始打破错误。

ImproperlyConfigured at / The included urlconf resume.urls doesn t have any patterns in it

恢复项目基础。 在环境中,我已经做了安排。

ROOT_URLCONF =  resume.urls 

这里,我恢复过来,坐在项目根名录上。

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns(  ,
    # Example:
    # (r ^resume/ , include( resume.foo.urls )),

    # Uncomment the admin/doc line below and add  django.contrib.admindocs  
    # to INSTALLED_APPS to enable admin documentation:
    (r ^admin/doc/ , include( django.contrib.admindocs.urls )),

    # Uncomment the next line to enable the admin:
    (r ^admin/ , include(admin.site.urls)),

    (r ^accounts/login/$ ,  django.contrib.auth.views.login ),


    #(r ^employer/ , include(students.urls)),

    (r ^ajax/ , include( urls.ajax )),
    (r ^student/ , include( students.urls )),
    (r ^club/(?P<object_id>d+)/$ ,  resume.students.views.club_detail ),
    (r ^company/(?P<object_id>d+)/$ ,  resume.students.views.company_detail ),
    (r ^program/(?P<object_id>d+)/$ ,  resume.students.views.program_detail ),
    (r ^course/(?P<object_id>d+)/$ ,  resume.students.views.course_detail ),
    (r ^career/(?P<object_id>d+)/$ ,  resume.students.views.career_detail ),

    (r ^site_media/(?P<path>.*)$ ,  django.views.static.serve , { document_root :  C:/code/django/resume/media }),

)

我有一把手叫ur和档案。 页: 1 (我还创建了一个空白的init.py in the same ́s so that urls be recognized.) 这是ja。

from django.conf.urls.defaults import *

urlpatterns = patterns(  ,
    (r ^star/(?P<object_id>d+)$ ,  resume.students.ajax-calls.star ),
)

任何人都知道什么错误? 这使我.。

感谢

最佳回答

检查您的格局,包括说明不存在哪些模块或单元没有<编码>/编码>成员。 我看到,你有一张<条码>,其中可能不正确。 是否应打上<条码>。

问题回答

TL;DR: 或许需要使用reverse_lazy()而不是reverse(>。

如果您的<代码>urls.py进口一种使用<代码>reverse(<>>/code>的基于类别的观点,你将发现这一错误;将使用<代码>reverse_lazy(<><>>>/code>加以确定。

对我来说,错误

包括“urlconf”项目。

由于:

  • project.urls imported app.urls
  • app.urls imported app.views
  • app.views had a class-based view that used reverse
  • reverse imports project.urls, resulting in a circular dependency.

Using 。 而不是reverse 这个问题已经解决:这推迟了该轮船的倒置,直到第一次需要时。

Moral: Always use reverse_lazy 如果你需要先扭转。

如果有的话,请核对你本人的正确改动名称:“

家长

" or any thing else. Correcting name helped me

核对变量的名称。

我的错误的起因是使用<代码>“urlspatterns”代替urlpatterns”

更正变量的名称解决了我的问题。

IN my case I got this error during deployment. Apache kept giving me the "AH01630: client denied by server configuration" error. This indicated that was wrong with apache configuration. To help troubleshoot I had turned on Debug=True in settings.py when I saw this error.

最后,我不得不在座右翼内部的静态档案配置中添加新的指令。 当静态档案无法查取时,在集延戈环境中的欺骗被确定为真实的,这一错误正在引发一些how。

我在试图利用RedirectView和url的参数来扭转(和逆转_lazy)这一错误。 犯罪法典认为:

from django.views.generic import RedirectView
from django.core.urlresolvers import reverse
url(r ^(?P<location_id>d+)/$ , RedirectView.as_view(url=reverse( dailyreport_location , args=[ %(location_id)s , ]))),

遗体是使用这种尿素:

from django.views.generic import RedirectView
url(r ^(?P<location_id>d+)/$ , RedirectView.as_view(url= /statistics/dailyreport/%(location_id)s/ )),

www.un.org/Depts/DGACM/index_spanish.htm 定型号使你能够继续使用卢尔型号:

from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
urlpatterns = patterns(  ,
    ....
    url(r ^(?P<location_id>d+)/$ , lambda x, location_id: HttpResponseRedirect(reverse( dailyreport_location , args=[location_id])), name= location_stats_redirect ),
    ....
)

就我而言,这是因为图形不包装。 我只剩下了一张ur子,其根本原因是<代码>。 ImproperlyConfigured 错误

TypeError:  URLPattern  object is not iterable

我最后使用了一条拖车,并解决这个问题。

urlpatterns = (url(...) , )

在我的案件中,我有以下错误:

Imp: 其中包含的“URLconf”似乎没有任何模式。 如果在档案中看到有效的模式,这个问题很可能是由循环进口造成的。

尿素模式是有效的,但问题是台风造成的进口错误。 页: 1

注:出于某种原因,在我拯救了另一个档案之后,这一错误也消失了。 因此,该错误首次出现,我保存了一个档案,其中我在<代码>forms.py文档中指明了错误的植被:

extra_field = forms.CharField(widget=forms.TextField())

而不是

extra_field = forms.CharField(widget=forms.TextInput()) 

在将其改为正确版本(TextInput)和保留表格之后。 简而言之,这一错误在我的奥索尔仍在显现。 在拯救另一个档案(例如模型.py)之后,该错误消失。

Check the imported modules in views.py if there is any uninstalled modules you found remove the module from your views.py file. It s Fix for me

django.urls.reverse()-->django.urls.reverse_lazy() This will instantly solve it.

在我的案件上,在应用urls.py的道路端使用 comma。 这个问题已经解决。

例如:

urlpatterns =[
    path(  , views.index, name= app )**,**
]

代码中的星号仅用于强调 com。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签