jjzjj

urlconfs

全部标签

python - 理解 Django 的 urlconf

我试图理解这一行:url(r'^(?P\d+)/$',views.detail,name='detail'),来自Django'stutorial关于如何创建View。特别是,我不明白以下内容:?P\d+名字='细节'urls.pyurlpatterns=patterns('',#ex:/polls/url(r'^$',views.index,name='index'),#ex:/polls/5/url(r'^(?P\d+)/$',views.detail,name='detail'),#ex:/polls/5/results/url(r'^(?P\d+)/results/$',vie

python - 属性错误 : 'RegexURLResolver' object has no attribute '_urlconf_module'

我在Sentry异常中不断收到以下错误AttributeError:'RegexURLResolver'对象没有属性'_urlconf_module'跟踪仅指向django代码库中的代码,而没有指向我的应用程序中的任何位置。我的日志也很干净。这可能是什么原因?raiseResolver404({'path':path})@propertydefurlconf_module(self):try:returnself._urlconf_moduleexceptAttributeError:self._urlconf_module=import_module(self.urlconf_nam

python - AttributeError: 'Settings' 对象没有属性 'ROOT_URLCONF'

继我的上一个问题Error:Nomodulenamedpsycopg2.extensions,我已将我的macOS更新为MountainLion并安装了Xcode。我还使用“sudoportinstallpy27-psycopg2”安装了psycopg2。我现在正在尝试运行“pythonmanage.pyrunserver”,但收到此错误AttributeError:'Settings'objecthasnoattribute'ROOT_URLCONF'关于如何解决这个问题并让我的本地主机运行的任何帮助? 最佳答案 来自django

python - AttributeError: 'Settings' 对象没有属性 'ROOT_URLCONF'

继我的上一个问题Error:Nomodulenamedpsycopg2.extensions,我已将我的macOS更新为MountainLion并安装了Xcode。我还使用“sudoportinstallpy27-psycopg2”安装了psycopg2。我现在正在尝试运行“pythonmanage.pyrunserver”,但收到此错误AttributeError:'Settings'objecthasnoattribute'ROOT_URLCONF'关于如何解决这个问题并让我的本地主机运行的任何帮助? 最佳答案 来自django

python - Django,动态 urlconfs,线程安全

我需要以线程安全的方式根据session中的数据动态生成urlpatterns。我通过一个自定义的URLResolver实现了这一点,它将url解析推迟到以后。我知道如何从中间件设置request.urlconf;但有一些原因我不能这样做(Django缓存解析器,在我的情况下会导致无限的内存使用)。我需要有人看一下实现,看看我是否正确处理了线程安全。谢谢!代码:我的应用程序/urls.py:urlpatterns=patterns('',#otherurlconfsurl(r'^/foo',include('foo.urls')),)foo/urls.py:importthreadin

python - 使用 mysite.urls 中定义的 URLconf,Django 尝试了这些 URL 模式,顺序为 :

我知道以前有人问过这个问题,但我还没有找到解决我的情况的答案。我在看Djangotutorial,并且我已经完全按照教程的方式设置了第一个URL,逐字逐句,但是当我转到http://http://localhost:8000/polls/时,它给了我这个错误:UsingtheURLconfdefinedinmysite.urls,DjangotriedtheseURLpatterns,inthisorder:^polls/^%[name='index']^admin/ThecurrentURL,polls/,didn'tmatchanyofthese.我正在使用Django1.10.5

python - 如何为不同分支中的 Django ROOT_URLCONF 设置设置正确的值

我已将django-adminstartproject创建的站点目录置于版本控制(Mercurial)之下。比方说,该网站名为frobnicator。现在我想进行一些认真的重构,所以我使用命令克隆该站点hgclonefrobnicatorfrobnicator-refactoring`但是settings.py中的ROOT_URLCONF仍然显示frobnicator.urls。有没有更好的方法来克服这个问题,而不是将站点移动到包装器目录中并将该目录存储在版本控制下(以在分支后保持相同的站点名称)或使用本地分支? 最佳答案 只需从R

python - 在 URLConf 中定义嵌套 namespace ,用于反转 Django URL——有人有令人信服的例子吗?

我一直在尝试弄清楚如何在DjangoURLConf中定义嵌套的URL命名空间(look:like:this)。在此之前,我想出了如何做一个基本的URL命名空间并想出了thissimpleexamplesnippet,包含您可能放入urls.py中的内容文件:fromdjango.conf.urlsimportpatterns,include,url#youcanonlydefineanamespaceforurlswhencallinginclude():app_patterns=patterns('',url(r'^(?P[\w\-]+)/$','yourapp.views.your

python - Django - 包含的 urlconf 中没有任何模式

我的网站,以前可以正常工作,突然开始出现错误ImproperlyConfiguredat/Theincludedurlconfresume.urlsdoesn'thaveanypatternsinit项目库称为简历。在settings.py我已经设置了ROOT_URLCONF='resume.urls'这是我的resume.urls,它位于项目根目录中。fromdjango.conf.urls.defaultsimport*#Uncommentthenexttwolinestoenabletheadmin:fromdjango.contribimportadminadmin.autod

Django urls 下划线的坑-Using the URLconf defined in xxx, Django tried these URL patterns, in thi

系统Win11Python版本3.10.4Django版本2浏览器:Chrome在文件名,url配置,view函数名等等,不要随便拼接下划线_,否则在浏览器访问的时候,容易报错。Pagenotfound(404)RequestMethod:GETRequestURL:http://127.0.0.1:8000/test_csrf/UsingtheURLconfdefinedinmysite7.urls,DjangotriedtheseURLpatterns,inthisorder:admin/test_cachetest_mwtest_csrfabcThecurrentpath,test_cs
12