怎么在django中获取URL上的参数
1个回答
展开全部
其实很简单
#coding:utf-8
from django.shortcuts import render,render_to_response
# Create your views here.
from django.http import HttpResponse
def hi(request):
user = {'user_id':1,'username':'张三','username':'李四'}
getUserName = request.GET.get('username')
print getUserName
return render_to_response("index.html",user)1234567891011
request.GET.get()就是获取url参数。
上面print getUserName打印结果为:zhangsan
#coding:utf-8
from django.shortcuts import render,render_to_response
# Create your views here.
from django.http import HttpResponse
def hi(request):
user = {'user_id':1,'username':'张三','username':'李四'}
getUserName = request.GET.get('username')
print getUserName
return render_to_response("index.html",user)1234567891011
request.GET.get()就是获取url参数。
上面print getUserName打印结果为:zhangsan
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询