How fix this? This after when i create new post and when i press button 'add'
It looks like your post is mostly code; please add some more details. Why stackoverflow ask this?
#models.py
from django.db import models
from django.contrib.auth.models import User
class Post(models.Model):
title = models.CharField(max_length=200)
slug = models.SlugField(max_length=255)
author = models.ForeignKey(User, on_delete= models.CASCADE,related_name='blog_posts')
content = models.TextField()
created_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(auto_now= True)
def __str__(self):
return self.title
#admin.py
from django.contrib import admin
from .models import Post
class PostAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',), }
admin.site.register(Post,PostAdmin)
Aucun commentaire:
Enregistrer un commentaire