django detail实现
来源:互联网 发布:鲁班安装预算软件 编辑:程序博客网 时间:2024/06/05 11:49
node2:/django1.8/mysite/polls#cat ../mysite/urls.py"""mysite URL ConfigurationThe `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/Examples:Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))"""from django.conf.urls import include, urlfrom django.contrib import adminurlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^polls/', include('polls.urls')),]node2:/django1.8/mysite/polls#cat urls.pyfrom django.conf.urls import urlfrom . import viewsurlpatterns = [ url(r'^$', views.index, name='index'), # ex: /polls/ url(r'^$', views.index, name='index'), # ex: /polls/5/ url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'), # ex: /polls/5/results/ url(r'^(?P<question_id>[0-9]+)/results/$', views.results, name='results'), # ex: /polls/5/vote/ url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'), url(r'^detail/(?P<question_id>[0-9]+)/$', views.detail, name='detail'),]node2:/django1.8/mysite/polls#cat views.py# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom django.http import HttpResponsefrom django.template import RequestContext, loaderfrom .models import Questionfrom django.http import HttpResponsefrom django.template import RequestContext, loaderfrom django.shortcuts import renderfrom .models import Questiondef index(request): latest_question_list = Question.objects.order_by('-pub_date')[:5] context = {'latest_question_list': latest_question_list} return render(request, 'polls/index.html', context)def detail(request, question_id): try: question = Question.objects.get(pk=question_id) except Question.DoesNotExist: raise Http404("Question does not exist") return render(request, 'polls/detail.html', {'question': question})def results(request, question_id): response = "You're looking at the results of question %s." return HttpResponse(response % question_id)def vote(request, question_id): return HttpResponse("You're voting on question %s." % question_id)node2:/django1.8/mysite/polls#cat templates/polls/detail.html <h1>----------</h1>{{ question }}<h1>----------</h1>
阅读全文
0 0
- django detail实现
- detail
- {'detail': 'Authentication credentials were not provided.'} django rest framework
- Master-Detail Application的纯代码实现
- django+Python的项目中出现 "detail": "CSRF Failed: CSRF cookie not set."
- 全局表实现Start Rountine和Rule Detail之间数据通信
- Win10 UWP开发系列:实现Master/Detail布局
- BCB下数据库报表Master/Detail关系功能的实现 |数据库报表,Master/Detail关系,主从复合结构
- client detail
- java detail
- ISKMP Detail
- libev detail
- SHOE DETAIL
- Java Detail
- Datagrieview detail
- Detail Texture
- java detail
- SGX Detail
- 理解tensorflow中的 placeholder
- ObjectBox[十二] Meta Model, IDs, and UIDs
- sqlServer 数据库备用/只读、受限制用户、正在还原 admin 2017-12-05 67 --数据库备用只读 恢复正常: USE master RESTORE DATABASE hi
- Date 的 toLocaleTimeString() 格式问题
- php利用curl实现多进程下载文件类
- django detail实现
- MyBatis JdbcType 与Oracle、MySql数据类型对应关系详解 (转)
- SQL行列处理
- Spring Mvc应用提示找不到HTTP映射,No Mapping found for httprequest
- Trafodion建表之使用多温度特性
- docker containerd 架构和源码简单分析
- retrofit2+okhttp3+rxjava网络封装
- fridge12_6
- css模块化