Class view Crud
Create App blog
models.py
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
author = models.ForeignKey(User,on_delete=models.CASCADE,null=True,blank=True)Add Model To Admin Panel
admin.py
from django.contrib import admin
from . models import Post
admin.site.register(Post)
Urls.py
Views.py
Templates
templates/blog/post_form.html
templates/blog/post_list.html
templates/blog/post_detail.html
templates/blog/post_confirm_delete.html
Last updated