Safari 中的 Django URL 模式有问题,但 Firefox 中没有?

发布于 2024-10-18 01:50:10 字数 2098 浏览 1 评论 0原文

刚接触 Django,遇到一个奇怪的问题:Firefox 在我们的应用程序中建立的 URL 模式下运行得很好,但 Safari 却崩溃并显示错误:

Django tried these URL patterns, in this order:
  ^admin/doc/
  ^admin/(.*)
  ^auth/
  ^game/
  ^static/(?P<path>.*)$
The current URL, , didn't match any of these.

所以看起来没有 URL 匹配,但为什么它适用于一个客户端和不是另一个? Safari 有什么不同?

编辑以包含 game/urls.py 和根级别 urls.py (应该有 2 个文件吗?):

(game/urls.py)

from django.conf.urls.defaults import *

urlpatterns = patterns('game.views',
    (r'^$', 'index'),
    (r'^dashboard/', 'dashboard'),
    (r'^details/(?P<venue_id>\d+)/$', 'details'),
)

(urls.py)

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'^starsquare/', include('starsquare.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'^admin/(.*)', admin.site.root),

    (r'^auth/', include('djangofoursquare.urls')),

    #game                                                                                                               
    (r'^game/',include('game.urls')),
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/username/dev/starsquare/game/static'})

)

new to Django, and encountering a strange issue: Firefox runs completely well with the URL patterns established in our app, but Safari bombs out with an error stating:

Django tried these URL patterns, in this order:
  ^admin/doc/
  ^admin/(.*)
  ^auth/
  ^game/
  ^static/(?P<path>.*)$
The current URL, , didn't match any of these.

So it looks like no URL is matching, but why would it work for one client and not another? What's different about Safari?

Edited to include game/urls.py and a root level urls.py (are there supposed to be 2 files?):

(game/urls.py)

from django.conf.urls.defaults import *

urlpatterns = patterns('game.views',
    (r'^

(urls.py)

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'^starsquare/', include('starsquare.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'^admin/(.*)', admin.site.root),

    (r'^auth/', include('djangofoursquare.urls')),

    #game                                                                                                               
    (r'^game/',include('game.urls')),
    (r'^static/(?P<path>.*)
, 'index'),
    (r'^dashboard/', 'dashboard'),
    (r'^details/(?P<venue_id>\d+)/

(urls.py)


, 'details'),
)

(urls.py)


, 'django.views.static.serve', {'document_root': '/home/username/dev/starsquare/game/static'})

)
, 'index'), (r'^dashboard/', 'dashboard'), (r'^details/(?P<venue_id>\d+)/

(urls.py)

, 'details'), )

(urls.py)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

扛刀软妹 2024-10-25 01:50:10

我相信这不是 Safari 的问题...好吧,你可以测试所有其他浏览器,但这应该没有什么区别。向我们展示您定义 url 模式的完整 urls.py 文件以及您尝试访问的 url。

I believe this is not the problem of Safari... OK, you can test all other browsers, but it shouldn't make difference. Show us your full urls.py file where you define the url patterns and also what url you trying to reach.

奢华的一滴泪 2024-10-25 01:50:10

如果您对 URL 进行了正确编码,那么在所有浏览器中应该都能正常工作。我不认为这是 Django 的问题。

向我们提供有关错误和 url 的更多信息。

If you encode the URL correctly then should work SAME in all browsers. I don't think this is a problem of Django.

give us more info about the error and the url.

好久不见√ 2024-10-25 01:50:10

感谢大家的意见,事实证明这是与 URL 中的服务器名称相关的配置问题。 server.com/ 可以工作,但 www.server.com/ 不行!其中一个浏览器指向一个 URL,而另一个浏览器则指向另一个。

Thanks to all for the sounding board, it turns out it was a configuration issue relating to the server name in the URL. server.com/ works, but www.server.com/ doesn't! One of the browsers was pointing at one URL, and the other browser at another.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文