django应用程序构建一个星球,rss/atom提要聚合器。

django-planet的Python项目详细描述


用法
=


检查"已安装的应用程序":

…代码块::python

installed廑apps=(
django required contrib apps
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
"django.contrib.staticfiles"、
"django.contrib.sitemaps"、
"第三方必需的应用程序:
"分页"、
"标记"、
"Pinax主题引导"、
"最后:
"Planet"、
)"2"。配置数据库。下面是一个使用mysql的示例:

…代码块::python

databases={
'默认值':{
'引擎':'django.db.backends.mysql',添加'postgresql'u psycopg2','postgresql','mysql','sqlite3'或'oracle'。
'名称':'planet','.
"用户":"<;myuser>;","不与sqlite3一起使用。
"密码":"<;mypass>;","不与sqlite3一起使用。
"主机":","设置为localhost的空字符串。未与sqlite3一起使用。
"端口":",默认设置为空字符串。不与sqlite3一起使用。
}
}


>3。选择站点ID:

…代码块:python

site_id=1

>4。对于django 1.8,包括以下上下文处理器:

…代码块::python

templates=[
{
'后端':'django.template.backends.django.djangotemplates',
'目录':[
'/path/to/project/templates',
],
'应用程序目录':true,
'选项':{
'上下文处理器s':[
django.template.context_processors.debug',
django.template.context_processors.request',
django.contrib.auth.context_processors.auth',
django.contrib.messages.context_processors.messages',
django.tempate.context廑processors.i18n',
'django.template.context廑processors.media',
'django.template.context廑processors.static',
'django.template.context廑processors.tz',
'planet.context廑processors.context',
],
},
]

如果仍在使用django 1.6.x或1.7.x,请按如下方式设置"模板上下文处理器"


。代码块::python

template_context_processors=(
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'planet.context_processors.context',


5.检查您的中间产品,包括:

…代码块::python

middleware类=(
'django.contrib.sessions.middleware.sessionmiddleware',
'django.middleware.common.commonmiddleware',
'django.middleware.csrf.csrfviewmiddleware',
'django.contrib.auth.middleware.authenticationmiddleware,
django.contrib.messages.middleware.messagemiddleware,
django.middleware.clickjacking.xframeoptionsmidleware,
pagination.middleware.paginationmiddleware,
)请不要忘记`` pagination.middleware.paginationmiddleware``中间器皿!

5.添加行星配置变量:

代码块:python

planet={
"用户代理":"我的星球/1.0",
}


>6。正确配置静态文件根目录:

…代码块::python

static_url='/static/'


7。仅适用于django 1.6.x或1.7.x设置项目模板根目录:

…代码块::python

template\u dirs=(
'/path/to/project/templates',
other path…



代码块::python

template\u loaders=(
'django.template.loaders.filesystem.loader',
'django.template.loaders.app\u directories.loader',
最后,在项目的template s目录中创建一个"site_base.html"`
模板(如果您还没有:

代码块:html

{%扩展了"base.html"%}



>9。或者,修改cookie名称,这样您就不会与其他
项目发生登录冲突:

…代码块::python

language_cookie_name="myplanetlng"
session_cookie_name="myplanetid"

恭喜!您的设置已完成。现在,您需要更改其他
文件才能获得正在运行的项目。

enable planet url
----


1。将planet url include添加到项目的"url.py"中(请记住
还包括管理员url,这样您就可以使用管理员来管理您的planet!):

…代码块::python

from django.conf.url导入模式,include,url

from django.contrib import admin
admin.autodiscover()

url(r'^',include('planet.url'),
url(r'^admin/',include(admin.site.url)),
其他url位…



syncdb并添加一些feed!
——然后创建数据库结构::

./manage.py syncdb

2。添加一些feed::

python manage.py planet_add_feed http://www.economonitor.com/feed/rss/
python manage.py planet_add_feed http://www.ft.com/rss/home/us

3.当然,您还需要添加一个cron条目来定期更新它们:

<30****python manage.py planet_update_a ll_feeds

这将尝试每隔30分钟发布一次新帖子。

<4。现在你完了。只需运行:

./manage.py runserver

,并在您喜爱的浏览器中浏览您的星球http://localhost:8000/!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java我的int值在SharedReferences中不被记住   java如何编辑Spring可分页对象?   java如何在gradle中单独调用任务   jvm以编程方式设置最大java堆大小   java如果满足多个条件,如何使用If语句计算数字?   如何在java中从json文件中获取特定值   如何在Sphinx4中为Java语音识别添加自定义语法?   java int[]copy=data;//当数据是数组时会发生什么?   java豪猪管理器。停下来。destroy()不起作用   安卓在API级别28中找不到画布变量   基于SOLID的java冗余   用于talend作业的java Liferay和portlet   从java到安卓的视频流   java获取在控件的类定义中添加自定义控件的场景大小   awt Java IndexOutOfBoundsException   java如何使用Spring JmsTemplate更改MQ头   java遍历数组并打印每个对象   java Google Map api v2标记在我旋转手机和地图“刷新”之前不会移动