from django.shortcuts import render
from django.http import HttpResponse
from .models import Board
# Create your views here.
def index(request):
s = 'СМР Блог\r\n\r\n\r\n'
for b in Board.objects.order_by('-published'):
s += b.title + '\r\n' + b.content + '\r\n'
return HttpResponse(s, content_type = 'text/plain; charset = utf-8')
from django.urls import path
from .views import index
urlpatterns = [
path('board/', index)#, name = 'index')
]
from django.db import models
# Create your models here.
class Board(models.Model):
title = models.CharField(max_length = 120)
content = models.TextField(max_length = 6000)
published = models.DateTimeField(auto_now_add = True, db_index = True)
TypeError: can only concatenate str (not "NoneType") to str