import json
data = {
'users': [
{
'id': 1,
'name': 'user1',
},
{
'id': 2,
'name': 'user2',
},
],
}
json_str = json.dumps(data)
{"users": [{"id": 1, "name": "user1"}, {"id": 2, "name": "user2"}]}
def sait(request):
return render(request, 'templates/sait.sait.html', locals())
def sait(request):
return render(request, 'sait/sait.html')
# models.py
from django.db import models
from django.contrib.auth.models import User
# Модель новости
class News(models.Model)
title = models.CharField(max_length=250, verbose_name='Заголовок')
text = models.TextField(verbose_name='Текст новости')
user = models.ForeignKey(User, verbose_name='Автор')