-1
我在嘗試使選擇器將頁面設置爲子頁面。我現在的代碼不起作用。如果頁面設置爲子頁面,我想存儲父頁面的ID。我認爲我的方式沒有道理,但我不知道另一種解決方案。錯誤是「沒有模塊命名頁面」。感謝您的幫助:d如何在django admin中使用選項中的查詢設置子頁面
import datetime
from django.db import models
from django.utils import timezone
from ckeditor.fields import RichTextField
from django.template.defaultfilters import slugify
from autoslug import AutoSlugField
from models.pages import Page
class Page(models.Model):
all_objects = Page.objects.all()
parent_page = [(0, 'Main page')]
parent_page = parent_page.extend([(x.id, x.page_title) for x in all_objects])
page_title = models.CharField(max_length=200)
admin_title = models.CharField(max_length=200, blank = True)
sub_page = models.IntegerField(default = 0, choises = parent_page)
content = RichTextField(blank = True)
slug = AutoSlugField(blank = True, populate_from='page_title', unique=True, editable=True)
pub_date = models.DateTimeField('date published')
view_status = models.IntegerField(default=1, choices=[(1, 'Active'), (2, 'Active, not displayed in menu'), (3, 'Inactive')])
def __str__(self):
return self.page_title
您的意思是**從pages.models導入頁**在進口? – avenet