mezzanine的page表
class Orderable(with_metaclass(OrderableBase, models.Model)):
"""
Abstract model that provides a custom ordering integer field
similar to using Meta's ``order_with_respect_to``, since to
date (Django 1.2) this doesn't work with ``ForeignKey("self")``,
or with Generic Relations. We may also want this feature for
models that aren't ordered with respect to a particular field.
""" _order = OrderField(_("Order"), null=True) class Meta:
abstract = True
class OrderableBase(ModelBase):
"""
Checks for ``order_with_respect_to`` on the model's inner ``Meta``
class and if found, copies it to a custom attribute and deletes it
since it will cause errors when used with ``ForeignKey("self")``.
Also creates the ``ordering`` attribute on the ``Meta`` class if
not yet provided.
"""
class Displayable(Slugged, MetaData, TimeStamped):
"""
Abstract model that provides features of a visible page on the
website such as publishing fields. Basis of Mezzanine pages,
blog posts, and Cartridge products.
""" status = models.IntegerField(_("Status"),
choices=CONTENT_STATUS_CHOICES, default=CONTENT_STATUS_PUBLISHED,
help_text=_("With Draft chosen, will only be shown for admin users "
"on the site."))
publish_date = models.DateTimeField(_("Published from"),
help_text=_("With Published chosen, won't be shown until this time"),
blank=True, null=True, db_index=True)
expiry_date = models.DateTimeField(_("Expires on"),
help_text=_("With Published chosen, won't be shown after this time"),
blank=True, null=True)
short_url = models.URLField(blank=True, null=True)
in_sitemap = models.BooleanField(_("Show in sitemap"), default=True) objects = DisplayableManager()
search_fields = {"keywords": 10, "title": 5} class Meta:
abstract = True
class Slugged(SiteRelated):
"""
Abstract model that handles auto-generating slugs. Each slugged
object is also affiliated with a specific site object.
""" title = models.CharField(_("Title"), max_length=500)
slug = models.CharField(_("URL"), max_length=2000, blank=True, null=True,
help_text=_("Leave blank to have the URL auto-generated from "
"the title.")) class Meta:
abstract = True class SiteRelated(models.Model):
"""
Abstract model for all things site-related. Adds a foreignkey to
Django's ``Site`` model, and filters by site with all querysets.
See ``mezzanine.utils.sites.current_site_id`` for implementation
details.
""" objects = CurrentSiteManager() class Meta:
abstract = True site = models.ForeignKey("sites.Site", editable=False) class MetaData(models.Model):
"""
Abstract model that provides meta data for content.
""" _meta_title = models.CharField(_("Title"), null=True, blank=True,
max_length=500,
help_text=_("Optional title to be used in the HTML title tag. "
"If left blank, the main title field will be used."))
description = models.TextField(_("Description"), blank=True)
gen_description = models.BooleanField(_("Generate description"),
help_text=_("If checked, the description will be automatically "
"generated from content. Uncheck if you want to manually "
"set a custom description."), default=True)
keywords = KeywordsField(verbose_name=_("Keywords"))
class TimeStamped(models.Model):
"""
Provides created and updated timestamps on models.
""" class Meta:
abstract = True created = models.DateTimeField(null=True, editable=False)
updated = models.DateTimeField(null=True, editable=False)
lass Page(BasePage):
"""
A page in the page tree. This is the base class that custom content types
need to subclass.
""" parent = models.ForeignKey("Page", blank=True, null=True,
related_name="children")
in_menus = MenusField(_("Show in menus"), blank=True, null=True)
titles = models.CharField(editable=False, max_length=1000, null=True)
content_model = models.CharField(editable=False, max_length=50, null=True)
login_required = models.BooleanField(_("Login required"), default=False,
help_text=_("If checked, only logged in users can view this page")) class Meta:
verbose_name = _("Page")
verbose_name_plural = _("Pages")
ordering = ("titles",)
order_with_respect_to = "parent"
model的Meta abstract为True的,不会生成数据库表。
CREATE TABLE "pages_page" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "keywords_string" varchar(500) NOT NULL, "title" varchar(500) NOT NULL, "slug" varchar(2000) NULL, "_meta_title" varchar(500) NULL, "description" text NOT NULL, "gen_description" bool NOT NULL, "created" datetime NULL, "updated" datetime NULL, "status" integer NOT NULL, "expiry_date" datetime NULL, "short_url" varchar(200) NULL, "in_sitemap" bool NOT NULL, "_order" integer NULL, "in_menus" varchar(100) NULL, "titles" varchar(1000) NULL, "content_model" varchar(50) NULL, "login_required" bool NOT NULL, "parent_id" integer NULL REFERENCES "pages_page" ("id"), "site_id" integer NOT NULL REFERENCES "django_site" ("id"), "publish_date" datetime NULL);
CREATE INDEX "pages_page_9365d6e7" ON "pages_page" ("site_id");
CREATE INDEX "pages_page_6be37982" ON "pages_page" ("parent_id");
CREATE INDEX "pages_page_76776489" ON "pages_page" ("publish_date");
mezzanine的page表的更多相关文章
- django之ModelBase类及mezzanine的page link类
class ModelBase(type): """ Metaclass for all models. """ def __new__(c ...
- mysql 数据库封装类:返回索引、关联、字符串数组;分页查询封装类 :$page=new Page(表的总条数,每页的条数);$sql = "".$page->limit; echo $page->fpage();
<?php class czy { public $host="localhost"; //地址 public $uid="root"; //用户名 pu ...
- [MySQL Reference Manual]14 InnoDB存储引擎
14 InnoDB存储引擎 14 InnoDB存储引擎 14.1 InnoDB说明 14.1.1 InnoDB作为默认存储引擎 14.1.1.1 存储引擎的趋势 14.1.1.2 InnoDB变成默认 ...
- Selenium Web 自动化 - 项目实战(三)
Selenium Web 自动化 - 项目实战(三) 2016-08-10 目录 1 关键字驱动概述2 框架更改总览3 框架更改详解 3.1 解析新增页面目录 3.2 解析新增测试用例目录 3. ...
- 7. redis优化
一. redis使用上的优化 精简键名和键值 键名:尽量精简,但是也不能单纯为了节约空间而使用不易理解的键名. 键值:对于键值的数量固定的话可以使用0和1这样的数字来表示,(例如:male/femal ...
- mysql ERROR 1064 (42000): Erreur de syntaxe près de 'order)
mysql> INSERT INTO page (author_username, page_title, addtime, cat_id, page_content,author_uid,it ...
- Flexigrid的API
基本设定 width table的长度(default:auto) height table的宽度(default:200) striped 表格的线的表示(default:true) nov ...
- Redis学习——Linux环境下Redis的安装(一)
一.关于Redis Redis最为一款开源的key-value存储系统,自推出到现在一直受到编程人员的喜爱.它支持存储多种value类型,String .List .Set .Zset .Hash.这 ...
- [No0000137]字符编码详解
摘要 本文主要介绍了字符编码的基础知识,以及常见的字符编码类型,比如ASCII,Unicode,UTF-8,ISO 8859等,以及各种编码之间的关系,同时专门解释了中文字符相关的编码标准,包括GB2 ...
随机推荐
- PHP 获取url里文件的扩展名
PHP 获取url地址中文件的扩展名 $url = 'http://www.abc.com/ab/cd/e.php?id=1&data=2#laowen';echo pathinfo( par ...
- 找不到 EntityType “ ” 的映射和元数据信息。
意思是: 数据库里边有添加的新字段DB1,而程序中的的实体即“元数据”中没有这个新字段Et1,由于EntityFramework更新模型时已自动默认对DB1和Et1进行了映射(默认认为实体中存在这个字 ...
- PyQt—QTableWidget中的checkBox状态判断
一.QTableWidget实现checkBox效果 利用QTableWidgetItem对象的CheckState属性,既能显示QCheckBox,又能读取状态 table = QtGui.QTab ...
- Osip2和eXosip协议栈的简析
Osip2是一个开放源代码的sip协议栈,是开源代码中不多使用C语言写的协议栈之一,它具有短小简洁的特点,专注于sip底层解析使得它的效率比较高. eXosip是Osip2的一个扩展协议集,它部分封装 ...
- 一个关于WCF调用远程链接返回405错误不允许使用此方法的问题
最近在调试WCF的接口时一直返回“405不允许使用此方法”,这个问题困扰了大半天,网上查了各种办法,但是每个人遇到的问题不同还是不能解决. 最后无意之中发现问题所在,记录一下帮助后面的同学解决问题. ...
- sql server 2008 R2 备份还原到sql 2012
从sql server 2008 r2备份的在sql server 2012中还原时一直读不到备份文件,然后把2008r2备份文件放到sql 2012的安装路径对应的Backup文件夹后可以读到了,不 ...
- javase每天内容总结(32期)
第一天 环境变量 编译与运行 dos命令 第二天 数据类型 运算符(三元) 第三天 引用数据类型(Scanner和Random) 流程控制语句 第四天 数组 第五天 方法(重载) 第六天 类 Arra ...
- java设计模式-Command模式
1.背景: 站在MM的角度,想命令追求者Boy干什么就干什么,而且将来还可以扩展,怎么做? 2.代码: Command.java: package com.cy.dp.command; publi ...
- 6行代码解决golang TCP粘包
转自:https://studygolang.com/articles/12483 什么是TCP粘包问题以及为什么会产生TCP粘包,本文不加讨论.本文使用golang的bufio.Scanner来实现 ...
- ES6的学习记录
1.let命令: 基本用法: ES6新增了let命令,用来声明变量.用法类似于var,但是所声明的变量只在let命令所在的代码块内有效. { let a = 10; var b = 1; } cons ...