简体   繁体   English

如何将我的index.html页面的href ID捕获到我的views.py文件中,并使用它在Django中呈现我的第二个html页面

[英]How do I capture the href id of my index.html page into my views.py file and use it to render my 2nd html page in Django

my HTML code 我的HTML代码

<html>
{% for d in name %}
<li><a id = {{d}} alt={{d|slugify }} href ="/hindi_guitarchords/{{d}}" 
class = "click">{{d}}</a> </li>
{% endfor %}
</html>

url.py code url.py代码

url(r'^hindi_guitarchords/(?P<d>.*)/$', 'guitarchordsapp.views.hindi_guitarchords'),

views.py views.py

def hindi_guitarchords(request, d):
    msg = request.POST.get('d')
    #msg= get_object_or_404(Post,slug=d)

    return render_to_response('hindi_guitarchords.html',{'song_name':msg})

Let me know if I'm missing something 让我知道我是否想念一些东西

代替msg = request.POST.get('d')msg = d

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Django 中的 views.py 获取变量并将其显示在我的 HTML 页面上 - How do I take a variable from views.py in Django and display it on my HTML page 如何将我的 index.html 连接到我的 views.py? - How will I connect my index.html to my views.py? Python Django如何无法从HTML文件上的views.py呈现我的变量 - Python Django how can't render my variables from views.py on html file 如何将在我的html文件上单击的图像的URL传递给views.py中的python函数 - how to pass the url of image clicked on my html file to my python function in views.py Django Django 2.0使用views.py呈现html页面(TemplateDoesNotExist) - Django 2.0 using views.py to render a html page (TemplateDoesNotExist) 我无法在要显示为html的views.py中使用我的models.py数据 - I am not able to use my models.py data in views.py that I want to display in as html 如何将对象数组从基于django类的视图发送到index.html文件? - How do I send an array of objects from a django class based view to my index.html file? 如何将 index.html 中的数据发送到 django 中的 views.py - How to send data from index.html to views.py in django 如何使用$ .post()将Jquery变量发送到我的views.py,以及如何在不刷新页面的情况下检索它们 - How do I send Jquery variable to my views.py using $.post(), and how do i retrieve them without refreshing the page 我无法在 Index.html 页面中查看此博客的帖子 - I Cant View my posts for this Blog in the Index.html page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM