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:03] – 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 275: | Line 276: | ||
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 291: | Line 299: | ||
from . import views | from . import views | ||
+ | |||
+ | app_name = " | ||
urlpatterns = [ | urlpatterns = [ | ||
Line 308: | Line 318: | ||
<ul> | <ul> | ||
{% for question in latest_question_list %} | {% for question in latest_question_list %} | ||
- | < | + | |
+ | < | ||
{% endfor %} | {% endfor %} | ||
</ul> | </ul> | ||
Line 315: | Line 326: | ||
{% endif %} | {% endif %} | ||
</ | </ | ||
+ | |||
+ | <file html polls/ | ||
+ | < | ||
+ | <ul> | ||
+ | {% for choice in question.choice_set.all %} | ||
+ | < | ||
+ | {% endfor %} | ||
+ | </ul> | ||
+ | </ | ||
+ | |||
+ | ====== Django Form ====== | ||
+ | |||
+ | https:// | ||
+ |
development/python/django.1724918637.txt.gz · Last modified: 2024/08/29 08:03 by tungnt