Mezzanine 1.3 升级 Mezzanine 3.0——一场噩梦

升级

理论方法

pip install mezzanine --upgrade
sudo python manage.py syncdb
sudo python manage.py migrate

其他需要考虑的几个问题

  1. Blogpost
  2. Blog Keyword
  3. Configure Setting

附带需要考虑的问题

  1. SEO
  2. 404
  3. Posts Blog

数据库

查看指定表

sudo python manage.py  sql blog

这个是原来的blog结构

BEGIN;
CREATE TABLE `blog_blogpost_related_posts` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `from_blogpost_id` integer NOT NULL,
    `to_blogpost_id` integer NOT NULL,
    UNIQUE (`from_blogpost_id`, `to_blogpost_id`)
)
;
CREATE TABLE `blog_blogpost_categories` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `blogpost_id` integer NOT NULL,
    `blogcategory_id` integer NOT NULL,
    UNIQUE (`blogpost_id`, `blogcategory_id`)
)
;
CREATE TABLE `blog_blogpost` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `comments_count` integer NOT NULL,
    `keywords_string` varchar(500) NOT NULL,
    `rating_count` integer NOT NULL,
    `rating_sum` integer NOT NULL,
    `rating_average` double precision NOT NULL,
    `site_id` integer NOT NULL,
    `title` varchar(500) NOT NULL,
    `slug` varchar(2000),
    `_meta_title` varchar(500),
    `description` longtext NOT NULL,
    `gen_description` bool NOT NULL,
    `created` datetime,
    `updated` datetime,
    `status` integer NOT NULL,
    `publish_date` datetime,
    `expiry_date` datetime,
    `short_url` varchar(200),
    `in_sitemap` bool NOT NULL,
    `content` longtext NOT NULL,
    `user_id` integer NOT NULL,
    `allow_comments` bool NOT NULL,
    `featured_image` varchar(255)
)
;
ALTER TABLE `blog_blogpost` ADD CONSTRAINT `site_id_refs_id_ac21095f` FOREIGN KEY (`site_id`) REFERENCES `django_site` (`id`);
ALTER TABLE `blog_blogpost` ADD CONSTRAINT `user_id_refs_id_01a962b8` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
ALTER TABLE `blog_blogpost_related_posts` ADD CONSTRAINT `from_blogpost_id_refs_id_6404941b` FOREIGN KEY (`from_blogpost_id`) REFERENCES `blog_blogpost` (`id`);
ALTER TABLE `blog_blogpost_related_posts` ADD CONSTRAINT `to_blogpost_id_refs_id_6404941b` FOREIGN KEY (`to_blogpost_id`) REFERENCES `blog_blogpost` (`id`);
ALTER TABLE `blog_blogpost_categories` ADD CONSTRAINT `blogpost_id_refs_id_6a2ad936` FOREIGN KEY (`blogpost_id`) REFERENCES `blog_blogpost` (`id`);
CREATE TABLE `blog_blogcategory` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `site_id` integer NOT NULL,
    `title` varchar(500) NOT NULL,
    `slug` varchar(2000)
)
;
ALTER TABLE `blog_blogcategory` ADD CONSTRAINT `site_id_refs_id_93afc60f` FOREIGN KEY (`site_id`) REFERENCES `django_site` (`id`);
ALTER TABLE `blog_blogpost_categories` ADD CONSTRAINT `blogcategory_id_refs_id_91693b1c` FOREIGN KEY (`blogcategory_id`) REFERENCES `blog_blogcategory` (`id`);

COMMIT;

新的blog

BEGIN;
CREATE TABLE "blog_blogpost_related_posts" (
    "id" integer NOT NULL PRIMARY KEY,
    "from_blogpost_id" integer NOT NULL,
    "to_blogpost_id" integer NOT NULL,
    UNIQUE ("from_blogpost_id", "to_blogpost_id")
)
;
CREATE TABLE "blog_blogpost_categories" (
    "id" integer NOT NULL PRIMARY KEY,
    "blogpost_id" integer NOT NULL,
    "blogcategory_id" integer NOT NULL,
    UNIQUE ("blogpost_id", "blogcategory_id")
)
;
CREATE TABLE "blog_blogpost" (
    "id" integer NOT NULL PRIMARY KEY,
    "comments_count" integer NOT NULL,
    "keywords_string" varchar(500) NOT NULL,
    "rating_count" integer NOT NULL,
    "rating_sum" integer NOT NULL,
    "rating_average" real NOT NULL,
    "site_id" integer NOT NULL REFERENCES "django_site" ("id"),
    "title" varchar(500) NOT NULL,
    "slug" varchar(2000),
    "_meta_title" varchar(500),
    "description" text NOT NULL,
    "gen_description" bool NOT NULL,
    "created" datetime,
    "updated" datetime,
    "status" integer NOT NULL,
    "publish_date" datetime,
    "expiry_date" datetime,
    "short_url" varchar(200),
    "in_sitemap" bool NOT NULL,
    "content" text NOT NULL,
    "user_id" integer NOT NULL REFERENCES "auth_user" ("id"),
    "allow_comments" bool NOT NULL,
    "featured_image" varchar(255)
)
;
CREATE TABLE "blog_blogcategory" (
    "id" integer NOT NULL PRIMARY KEY,
    "site_id" integer NOT NULL REFERENCES "django_site" ("id"),
    "title" varchar(500) NOT NULL,
    "slug" varchar(2000)
)
;

COMMIT;

迁移

数据问题

1.Blog标签问题

删除的内容

 {% keywords_for blog.blogpost as tags %}

路径

/home/www/MK_phodal/templates/blog/includes/change_list.html
  1. pytz问题

删除的内容

{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

路径

/usr/lib/python2.6/site-packages/grappelli_safe/templates/admin/filter_panel.html

关于我

Github: @phodal     微博:@phodal     知乎:@phodal    

微信公众号(Phodal)

围观我的Github Idea墙, 也许,你会遇到心仪的项目

QQ技术交流群: 321689806