嘿伙计们我在django面临一个错误? [英] Hey guys I am facing an error in django ?
问题描述
伙计我试图将我的网址与我的html文件的锚标签相关联,但是我得到了一个没有反向匹配的错误,我试图关联的文件也是正确的位置,也是在视图和网址中初始化的。
这里是这个相对视图的views.py代码
来自django.shortcuts导入的
渲染
#在这里创建你的看法。
def relative(请求):
返回渲染(请求, 'second_app / relative.html')
这里的urls.py代码不是django,我自己的文件网址,但我创建的那个
来自django.conf.urls import url
来自second_app导入视图
#模板标记
app_name ='second_app'
urlpatterns = [
url(r'^ relative / $',views.relative),
url(r'^ other /',views.other)
]
这里是html代码
<!DOCTYPE html>
< title>嘿
点击下面的链接
其他页面
我尝试了什么:
我厌倦了像这样{%url'relative'%}写一个模板标签,我也试着找到堆栈溢出的答案。
Guys I am tried to relate my url in anchor tag of my html file but I am getting a no reverse match error ,The file i am trying to relate is having the right location also it, been initialised in views and urls too .
Here,s the views.py code for this relative view
from django.shortcuts import render
# Create your views here.
def relative(request):
return render(request,'second_app/relative.html')
Here,s the urls.py code not the django,s own file urls but the one i created
from django.conf.urls import url
from second_app import views
# TEMPLATE TAGGING
app_name = 'second_app'
urlpatterns = [
url(r'^relative/$',views.relative),
url(r'^other/',views.other)
]
Here,s the html code
<!DOCTYPE html>
<title>hey
Hey click on the link below
Other page
What I have tried:
I tired to write the template tagging in achor tg like this {% url 'relative' %} and I also tried to find the answer on stack overflow.
推荐答案
',views。亲戚),
url(r'^ other /',views.other)
]
这里是html代码
<!DOCTYPE html> ;
< title>嘿
点击以下链接
其他页面
我的尝试:
我厌倦了像这样的{%url'相对'%}来编写模板标签,我也试图找到堆栈溢出的答案。
',views.relative),
url(r'^other/',views.other)
]
Here,s the html code
<!DOCTYPE html>
<title>hey
Hey click on the link below
Other page
What I have tried:
I tired to write the template tagging in achor tg like this {% url 'relative' %} and I also tried to find the answer on stack overflow.
这篇关于嘿伙计们我在django面临一个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!