development:python:django
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
development:python:django [2024/08/29 08:02] – [Django Views] tungnt | development:python:django [2024/08/29 08:32] (current) – [Django Views] tungnt | ||
---|---|---|---|
Line 259: | Line 259: | ||
<file python polls/ | <file python polls/ | ||
- | from django.shortcuts import render | + | from django.shortcuts import |
from django.template import loader | from django.template import loader | ||
from django.http import HttpResponse | from django.http import HttpResponse | ||
+ | from django.http import Http404 | ||
from .models import Question | from .models import Question | ||
Line 271: | Line 272: | ||
" | " | ||
} | } | ||
- | return HttpResponse(template.render(context, | + | |
+ | return render(request, | ||
def detail(request, | def detail(request, | ||
- | | + | |
+ | # question = Question.objects.get(pk=question_id) | ||
+ | #except Question.DoesNotExist: | ||
+ | # raise Http404("Question does not exist" | ||
+ | |||
+ | | ||
+ | |||
+ | return render(request, | ||
Line 290: | Line 299: | ||
from . import views | from . import views | ||
+ | |||
+ | app_name = " | ||
urlpatterns = [ | urlpatterns = [ | ||
Line 307: | Line 318: | ||
<ul> | <ul> | ||
{% for question in latest_question_list %} | {% for question in latest_question_list %} | ||
- | < | + | |
+ | < | ||
{% endfor %} | {% endfor %} | ||
</ul> | </ul> | ||
Line 314: | Line 326: | ||
{% endif %} | {% endif %} | ||
</ | </ | ||
+ | |||
+ | <file html polls/ | ||
+ | < | ||
+ | <ul> | ||
+ | {% for choice in question.choice_set.all %} | ||
+ | < | ||
+ | {% endfor %} | ||
+ | </ul> | ||
+ | </ | ||
+ | |||
+ | ====== Django Form ====== | ||
+ | |||
+ | https:// | ||
+ |
development/python/django.1724918577.txt.gz · Last modified: 2024/08/29 08:02 by tungnt