zoukankan      html  css  js  c++  java
  • django get请求传参

    node2:/django/mysite/blog#cat views.py
    # -*- coding: utf-8 -*-
    from __future__ import unicode_literals
    # from django.shortcuts import render, render_to_response
    from .models import *
    # Create your views here.
    from django.http import HttpResponse
    from django.template import loader
    
    def archive(req):
      print 'aaaaaaaaaaaaaaaaaaaaaaaaaaa'
      print req
      print type(req)
      print req.GET
      print '#############################'
      print req.GET['aa']
      print req.GET['cc']
      print '#############################'
      print 'aaaaaaaaaaaaaaaaaaaaaaaaaaa'
    # get all blogpost objects
      posts = BlogPost.objects.all()
      #print blog_list
      template = loader.get_template('archive.html')
      context = {
      'posts':posts
      }
      print '------------------------------------------'
      print  HttpResponse(template.render(context, req))
      print '------------------------------------------'
      return HttpResponse(template.render(context, req))
    node2:/django/mysite/blog#
    
    
    http://192.168.137.3:8000/blog/?aa=1234&cc=5678
    
    
    aaaaaaaaaaaaaaaaaaaaaaaaaaa
    <WSGIRequest: GET '/blog/?aa=1234&cc=5678'>
    <class 'django.core.handlers.wsgi.WSGIRequest'>
    <QueryDict: {u'aa': [u'1234'], u'cc': [u'5678']}>
    #############################
    1234
    5678
    #############################
    aaaaaaaaaaaaaaaaaaaaaaaaaaa
    

  • 相关阅读:
    关于C++类中的静态数据成员
    关于C++中char,sizeof,strlen,string
    C++学习笔记(7)
    C++学习笔记(6)
    C++学习笔记(指针)
    C++学习笔记(4)
    UVA 10780
    UVA 531
    HDU, 3579 Hello Kiki
    UVA, 10413 Crazy Savages
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349431.html
Copyright © 2011-2022 走看看