End tuto03
This commit is contained in:
21
CppProperties.json
Normal file
21
CppProperties.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"inheritEnvironments": [
|
||||||
|
"msvc_x86"
|
||||||
|
],
|
||||||
|
"name": "x86-Debug",
|
||||||
|
"includePath": [
|
||||||
|
"${env.INCLUDE}",
|
||||||
|
"${workspaceRoot}\\**"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"WIN32",
|
||||||
|
"_DEBUG",
|
||||||
|
"UNICODE",
|
||||||
|
"_UNICODE"
|
||||||
|
],
|
||||||
|
"intelliSenseMode": "windows-msvc-x86"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
6
polls/templates/polls/detail.html
Normal file
6
polls/templates/polls/detail.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<h1>{{ question.question_txt }}</h1>
|
||||||
|
<ul>
|
||||||
|
{% for choice in question.choice_set.all %}
|
||||||
|
<li>{{ choice.choice_txt }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
10
polls/templates/polls/index.html
Normal file
10
polls/templates/polls/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{% if latest_question_list %}
|
||||||
|
<h1>Liste des questions:</h1>
|
||||||
|
<ul>
|
||||||
|
{% for question in latest_question_list %}
|
||||||
|
<li><a href="{% url 'polls:detail' question.id %}/">{{ question.question_txt }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No polls are available.</p>
|
||||||
|
{% endif %}
|
@@ -3,6 +3,13 @@ from django.urls import path
|
|||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
app_name = "polls"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('',views.index, name='index'),
|
path('',views.index, name='index'),
|
||||||
|
# ex: /polls/5/
|
||||||
|
path('specifics/<int:question_id>/', views.detail, name='detail'),
|
||||||
|
# ex: /polls/5/results/
|
||||||
|
path('<int:question_id>/results/', views.results, name='results'),
|
||||||
|
# ex: /polls/5/vote/
|
||||||
|
path('<int:question_id>/vote/', views.vote, name='vote'),
|
||||||
]
|
]
|
@@ -1,6 +1,26 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import get_object_or_404, render
|
||||||
|
from django.http import Http404
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
|
||||||
|
from polls.models import *
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
return HttpResponse("Hello, world kirosbr ! test 2")
|
latest_question_list = Question.objects.order_by("-pub_date")[:5]
|
||||||
# Create your views here.
|
|
||||||
|
context = {
|
||||||
|
"latest_question_list": latest_question_list,
|
||||||
|
}
|
||||||
|
|
||||||
|
return render(request, 'polls/index.html', context)
|
||||||
|
|
||||||
|
def detail(request, question_id):
|
||||||
|
question = get_object_or_404(Question, pk=question_id)
|
||||||
|
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("Tu réponds à la question %s." % question_id)
|
||||||
|
Reference in New Issue
Block a user