django
django
PHODAL

查看标签 django

试试django-cms 3.0带来了什么新的东西,之前的django-cms有点让人失望,就转到了mezzanine门下。

原文

升级 理论方法 pip install mezzanine --upgrade sudo python manage.py syncdb sudo python manage.py migrate

其他需要考虑的几个问题

Blogpost Blog Keyword Configure Setting

附带需要考虑的问题

SEO 404 Posts Blog

数据库 查看指定表 sudo python manage.py sql blog

这个是原来的blog结构

从1.4升级到1.6似乎是一个很简单的过程,如果光从Django的角度来说的话,不是很难,过程中,只添加了一个ALLOWED_HOSTS

开始之前了解一下Mezzanine是什么:

> Mezzanine is a powerful, consistent, and flexible content management platform. Built using the Django framework, Mezzanine provides a simple yet highly extensible architecture that encourages diving in and hacking on the code. Mezzanine is BSD licensed and supported by a diverse and active community. > In some ways, Mezzanine resembles tools such as Wordpress that provide an intuitive interface for managing pages, blog posts, form data, store products, and other types of content. But Mezzanine is also different. Unlike many other platforms that make extensive use of modules or reusable applications, Mezzanine provides most of its functionality by default. This approach yields a more integrated and efficient platform.

这也就是官方的简介,简单地说Mezzanine就是一个基于Django框架的应用,同时他提供了类似于wordpress的功能。换句话说,Mezzanine就是一个wordpress,我们只需要简单的修改就可以部署了。一个新项目创建时的截图,


我们可以看到Mezzanine用作商业的时候是如此的简单明了。

详细可以参考官方网站:http://mezzanine.jupo.org/

Mezzanine快速指引

# Install from PyPI
$ pip install mezzanine

# Create a project
$ mezzanine-project myproject
$ cd myproject

# Create a database
$ python manage.py createdb

# Run the web server
$ python manage.py runserver

这也就完成了本地开发的第一部。我们可以发现,新建的项目里面我们很难修改主题,如下所示

3240	./static/media/uploads/gallery
3244	./static/media/uploads
3248	./static/media
3252	./static
24	./deploy
8	./requirements
12	./templates
3520	.

可以使用

python manage.py collecttemplates --help

收集templates

因而,我们需要另外的文件,也就是templates,这个没有在需要额外配置。


git clone https://github.com/renyi/mezzanine-themes.git

然后复制目录中的mazzanine_themes/mazzanine_default到templates中,这样就可以修改默认的样式了。

关于部署由于之前静态文件的设置问题,因此也就贴了出来。换句话说,默认的静态文件和Django一样需要修改网站nginx的配置文件,比如我的是www.phodal.com.conf。

 

location /static {
	autoindex on;
	alias /home/gmszone/Phodal/static;
	access_log off;
	log_not_found off;
}

location /robots.txt
	alias /home/gmszone/Phodal/static;
	access_log off;
	log_not_found off;
}
location /favicon.ico {
	alias /home/gmszone/Phodal/static/img;
	access_log off;
	log_not_found off;
}

也就是要由nginx指定static的位置,也就没有那么多,只需要。记得重启一下nginx

alias /home/gmszone/Phodal/static;

至于部署方式可以采用,uWSGI。

安装完uWSGI需要,两个文件以便使之运作。

import os,sys

if not os.path.dirname(__file__) in sys.path[:1]:
    sys.path.insert(0, os.path.dirname(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

也就wsgi.py,以及

<uwsgi>
    <socket>127.0.0.1:8630</socket>
    <chdir>/home/gmszone/Phodal</chdir>
    <pythonpath>..</pythonpath>
    <module>wsgi</module>
</uwsgi>

最后再运行,

uwsgi -x /home/gmszone/Phodal/wsgi.xml

详细可以参照:http://projects.unbit.it/uwsgi/wiki/Example


安装Django REST. - Python (2.5, 2.6, 2.7 supported) - Django (1.2, 1.3, 1.4 supported)django.contrib.staticfiles (or django-staticfiles for Django 1.2) - URLObject <= 2.0.0 - Markdown <= 2.1.0 (Optional) - PyYAML <= 3.10 (Optional)

使用pip或者easy_install

So,开始之前你需要什么?

关于openwrt

OpenWrt的被描述为一个嵌入式设备的Linux发行版,而不是试图建立一个单一的,静态的固件,OpenWrt的包管理提供了一个完全可写的文件系统,从应用程序供应商提供的选择和配置,并允许您自定义的设备,以适应任何应用程序通过使用包。对于开发人员,OpenWrt的是框架来构建应用程序,而无需建立一个完整的固件左右;对于用户来说,这意味着完全定制的能力,从来没有预想的方式使用该设备。

装有Openwrt的路由器              一个       使你的路由器能上网

所以,你需要买上一个路由器,或者用自带的,至于各种教程就网上找吧。如果不知道Openwrt是什么请谷歌,如果你的路由器不能上网,带有无线的话,试着用connectify共享出你的网络。

需要安装libffi,python-mini,python。libffi以及python-mini需要安装在python之前

So,开始之前你需要什么?

装有Openwrt的路由器              一个       使你的路由器能上网

所以,你需要买上一个路由器,或者用自带的,至于各种教程就网上找吧。如果不知道Openwrt是什么请谷歌,如果你的路由器不能上网,带有无线的话,试着用connectify共享出你的网络。

安装IIS。

Feeds

RSS / Atom

最近文章

关于作者

Phodal Huang

Engineer, Consultant, Writer, Designer

ThoughtWorks 技术专家

工程师 / 咨询师 / 作家 / 设计学徒

开源深度爱好者

出版有《前端架构:从入门到微前端》、《自己动手设计物联网》、《全栈应用开发:精益实践》

联系我: h@phodal.com

微信公众号: 最新技术分享

存档

分类

标签

作者