阿小信大人的头像
Talk is cheap. Show me the code. Linus Torvalds

Django模拟新浪微博的@功能2014-09-02 05:04

在论坛加了个类似微博的@功能,在回复帖子的时候可以@系统中的用户,被@的用户可以收到自己被@的通知可以做出相应的处理。

关于model

:::python
#-*- coding:utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
import datetime
from geek.geekchallenge.models import *
from django.db.models.signals i

......
#Python#   #django 评论[0]阅读全文[2305]

Django中使用Signals笔记2014-09-02 04:45

:::python
# -*- coding:utf-8 -*-
# reference:http://jinhao.iteye.com/blog/218346
from django.db import models
from django.contrib import admin
##test signals
#app's models.py a good place to put registration of signal handlers.
from django.db.models.signals imp

......
#Python#   #django 评论[0]阅读全文[2440]

在OpenShift上部署Django项目2014-09-02 04:44

在OpenShift上部署Django项目


帮助文档:

https://openshift.redhat.com/community/developers/python

https://github.com/openshift/django-example


0.安装所需环境:

ashin@linux:~$ sudo apt-get install ruby-full rubygems git-core

各操作系统的安装方法:https://openshift.redhat.com/community/developers/install-

......
#Python#   #django 评论[0]阅读全文[3007]

Django使用flatpages2014-09-02 04:39

1.添加app :'django.contrib.flatpages',依赖django.contrib.sites,

2.添加中间件:'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',

3.manage.py syncdb

4.在app的模板目录下新建文件platpages/default.html

:::html
{% extends "base.html" %}
{% block title %}
{{ flatpage.titl

......
#Python#   #django 评论[0]阅读全文[1608]

Django自定义模板过滤器2014-09-02 04:39

首先给出方法:

:::python
# -*- coding: utf-8 -*-
from django.template import Library
register = Library()

# django模板中没有'world' in 'hello world'这样的
@register.filter
def contains(value, arg):
return arg in value.decode('uft-8')
# 用法 {% if str|contains:'你'

......
#Python#   #django 评论[0]阅读全文[1184]