Django入门指南-第6章:第一个视图函数(完结)

# boards/views.py
from django.http import HttpResponse
from .models import Board

def home(request):
    boards = Board.objects.all()
    boards_names = list()

    for board in boards:
        boards_names.append(board.name)

    response_html = '<br>'.join(boards_names)

    return HttpResponse(response_html)

猜你喜欢

转载自www.cnblogs.com/larken/p/9590178.html