我创建了一个名为“定价”的新应用(manage.py startapp pricing
)。
前端工作正常。现在我想在我的django-cms管理员中添加额外的字段,用户可以在Db中存储,更改,为此应用添加新值。
用几句话:我想将我的应用程序中的模型注册到django-cms admin。我希望它出现在管理页面的底部。
mycms:
mysite
static
templates
**pricing(my app)
templates
admin.py
models.py
test.py
views.py**
cms_plugins.py
forms.py
models.py
settings.oy
urls.py
views.py
pricing app
:
models.py
from django.db import models
# Create your models here.
class Post(models.Model):
introduction = models.CharField(max_length=200)
offer_option = models.TextField()
prop_one = models.TextField()
prop_two = models.TextField()
prop_three = models.TextField()
price = models.TextField()
period = models.TextField()
def __str__(self):
return self.offer_option
views.py
:
from django.shortcuts import render
from django.utils import timezone from .models import Post
def post_list(request):
posts = Post.objects.all()
return render(request, 'post_list.html', {'posts': posts})
admin.py
:
from django.contrib import admin
# Register your models hefrom django.contrib import admin
from .models import Post
admin.site.register(Post)