Django 无法路由 url(简单问题)
我正在做一些愚蠢的事情,而且我不确定那是什么。我的 django 项目的根目录中有以下 urls.py:
from django.conf.urls.defaults import *
from django.conf import settings
urlpatterns = patterns('',
(r'^$', include('preview_signup.urls')),
)
在我的 Preview_signup 模块(django 应用程序)中,我有以下 urls.py 文件:
from django.conf.urls.defaults import *
urlpatterns = patterns('django.views.generic.simple',
(r'^thanks/$', 'direct_to_template', {'template': 'thankyou.html'})
)
当我转到 http://localhost:8000/thanks/。但如果改为这样:
from django.conf.urls.defaults import *
urlpatterns = patterns('django.views.generic.simple',
(r'^$', 'direct_to_template', {'template': 'thankyou.html'})
)
我转到 http://localhost:8000/ 它工作正常。
我做错了什么?
I'm doing something stupid, and I'm not sure what it is. I have a the following urls.py in the root of my django project:
from django.conf.urls.defaults import *
from django.conf import settings
urlpatterns = patterns('',
(r'^
In my preview_signup module (django app) I have the following urls.py file:
from django.conf.urls.defaults import *
urlpatterns = patterns('django.views.generic.simple',
(r'^thanks/
The urls.py above doesn't work when I go to http://localhost:8000/thanks/. But if it's changed to this:
from django.conf.urls.defaults import *
urlpatterns = patterns('django.views.generic.simple',
(r'^
And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
, include('preview_signup.urls')),
)
In my preview_signup module (django app) I have the following urls.py file:
The urls.py above doesn't work when I go to http://localhost:8000/thanks/. But if it's changed to this:
And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
, 'direct_to_template', {'template': 'thankyou.html'})
)
The urls.py above doesn't work when I go to http://localhost:8000/thanks/. But if it's changed to this:
And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
, include('preview_signup.urls')),
)
In my preview_signup module (django app) I have the following urls.py file:
The urls.py above doesn't work when I go to http://localhost:8000/thanks/. But if it's changed to this:
And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
, 'direct_to_template', {'template': 'thankyou.html'}) )And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
, include('preview_signup.urls')), )In my preview_signup module (django app) I have the following urls.py file:
The urls.py above doesn't work when I go to http://localhost:8000/thanks/. But if it's changed to this:
And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
, 'direct_to_template', {'template': 'thankyou.html'}) )The urls.py above doesn't work when I go to http://localhost:8000/thanks/. But if it's changed to this:
And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
, include('preview_signup.urls')), )In my preview_signup module (django app) I have the following urls.py file:
The urls.py above doesn't work when I go to http://localhost:8000/thanks/. But if it's changed to this:
And I go to http://localhost:8000/ it works fine.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此代码应该有效:
$(行尾)刚刚删除。
This code should work:
$ (end of line) just removed.
当出现问题时(或者即使没有出现问题),请仔细阅读 django 文档。以下是上述链接的摘录:
When something goes wrong (or even if it doesn't), thoroughly read the django docs. Here's an excerpt from the aforementioned link: