- post to each other's wall
- new events
自定义signal
定义,appname.signals.py
import django.dispatch
new_picture = django.dispatch.Signal()
sender 发送,appname_xyz.views.py
from status.signals import new_picture
...
new_picture.send(Picture, picture=picture, album=album)
listener 监听,appname.models.py
from appname.signals import new_picture
def new_picture_listener(sender, picture, album, **kwargs):
'''
Update or generate a status update, when a user upload a new picture.
'''
#...
# logic here
#...new_picture.connect(new_picture_listener, sender=Picture)
What's on your mind. JS
<script type="text/javascript">
{% if is_me %}
var message = 'What/'s on your mind?';
{% endif %}
{% if is_friend %}
var message = 'Write something...';
{% endif %}
var has_value = false;
function click_text(){C
if(has_value == false){
$('#id_text').val('')
}
}
function blur_text(){
var val = $("#id_text").val()
//console.log(val)
if (val){
has_value = true;
}else{
has_value = false;
$("#id_text").val(message);
}
}
$(function(){
$('#id_text').val(message);
$('#id_text').click(click_text).blur(blur_text);
})
</script>
CSV 导入与 image
当一个图片被赋值为 Satchmo 的产品图片的时候,图片的文件名可能被修改(根据 livesettings 中的设置),这就导致了多个产品使用同一个图片的时候会造成问题。
satchmo_utils.thumbnail.field
self.auto_rename = config_value('THUMBNAIL', 'RENAME_IMAGES')
所以需要在ProductImage.save() 之前对图片文件进行备份,然后再上传之后对备份进行恢复。