This is my models:
from django.db import models
# Create your models here.
class post(models.Model):
title = models.CharField(max_length=255)
body = models.TextField()
date = models.DateTimeField(auto_now_add=True)
and this is my views in django
from django.shortcuts import render
from .models import post
from django.http import HttpResponse
# Create your views here.
def post(request, id):
data = {'post': post.objects.get(id=id)}
return render(request, 'post/post.html', data)
I try to get post by id but error found:
AttributeError at /post/3/
'function' object has no attribute 'objects'