我这样写了我的模型:
from django.db import models
from ckeditor.fields import RichTextField
from django import forms
from django.contrib import admin
from ckeditor.widgets import CKEditorWidget
import datetime
class Post(models.Model):
title = models.CharField(max_length=200,default="no-title")
tags = models.CharField(max_length=200,default="blog",help_text="comma separated")
summary = models.TextField(max_length=300,default="summary",help_text="Article short introduction")
cover = models.ImageField("cover img",upload_to="blog/")
last_activity = models.DateTimeField(default=datetime.datetime.now,auto_now=True)
keywords = models.CharField(max_length=200,default="no-keyword",help_text="comma separated")
content = RichTextField()
def __unicode__(self):
return self.title
class PostAdminForm(forms.ModelForm):
content = forms.CharField(widget=CKEditorWidget())
fields = ('title','tags')
class Meta:
model = Post
class PostAdmin(admin.ModelAdmin):
form = PostAdminForm
readonly_fields = ('last_activity',)
admin.site.register(Post, PostAdmin)
我的模型显示在管理页面中,如下所示:
您可以看到Tags
列输入文本和垂直显示的help_text
字符串,这不是我想要的,我想显示Tags
列输入文本和{ {1}}水平属性。