可能重复:
多语言数据库的模式
这是一个例子:
[ products ]
id (INT)
name-en_us (VARCHAR)
name-es_es (VARCHAR)
name-pt_br (VARCHAR)
description-en_us (VARCHAR)
description-es_es (VARCHAR)
description-pt_br (VARCHAR)
price (DECIMAL)
Run Code Online (Sandbox Code Playgroud)
问题是:每种新语言都需要修改表结构.
这是另一个例子:
[ products-en_us ]
id (INT)
name (VARCHAR)
description (VARCHAR)
price (DECIMAL)
[ products-es_es ]
id (INT)
name (VARCHAR)
description (VARCHAR)
price (DECIMAL)
Run Code Online (Sandbox Code Playgroud)
问题是:每种新语言都需要创建新表,并且"价格"字段在每个表中都是重复的.
这是另一个例子:
[ languages ]
id (INT)
name (VARCHAR)
[ products ]
id (INT)
price (DECIMAL)
[ translation ]
id (INT, PK)
model (VARCHAR) // product
field (VARCHAR) // name
language_id (INT, …Run Code Online (Sandbox Code Playgroud) 我开始组织一个新项目,让我说我会有几个模型,如产品和目录.
我将允许我的客户(不是访客,只有特定客户)登录Django Admin站点来创建,编辑和删除他们自己的目录.
假设我创建了一个名为"Shop"的模型,创建每个商店(名称,地址,徽标,联系信息等)并创建一个绑定到该商店的管理员用户.
现在我想要这个新的管理员(谁不是网站管理员,但是商店管理员 - 可能是用户组)只能查看和编辑与他的商店链接的目录.
那可能吗?
我应该在Django Admin中执行此操作还是应该创建一个新的"shop admin"应用程序?
我已经设置了我的环境,所以我可以推送到远程裸存储库,我使用这些命令来设置远程存储库:
$ mkdir ~/website.git && cd ~/website.git
$ git init --bare
Run Code Online (Sandbox Code Playgroud)
和
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/website git checkout -f
$ chmod +x hooks/post-receive
Run Code Online (Sandbox Code Playgroud)
在我的本地环境中:
$ git remote add web ssh://website.com/home/website.git
$ git push web +master:refs/heads/master
Run Code Online (Sandbox Code Playgroud)
现在我可以部署到这个远程使用git push web,一切都很好..
我的项目中有一些子模块没有在远程存储库中初始化/更新...我无法git submodule update在裸机上运行,因为它是裸的,我不能在/var/www/website文件夹上运行它,因为它只是一个副本的文件而不是git repo.
我正在使用Google Maps API v3显示地图,加载一些KML并使用kml.setMap()方法显示/隐藏它们.
我需要在加载KML时显示"加载"窗口,直到地图完成加载.
我试着用这样的东西:
google.maps.event.addListener(map, 'tilesloaded', function() {
var d = new Date();
console.log('Loaded: ' + d);
});
google.maps.event.addListener(map, 'bounds_changed', function() {
var d = new Date();
console.log('Started: ' + d);
});
Run Code Online (Sandbox Code Playgroud)
但它没有按预期工作.
"titlesloaded"事件总是不会被触发,可能是因为缓存的图像?
这是我的日志:
Started: Tue Mar 29 2011 16:22:03 GMT-0300 (BRT) <-- started loading map
Loaded: Tue Mar 29 2011 16:22:06 GMT-0300 (BRT) <-- done loading map
Started: Tue Mar 29 2011 16:22:30 GMT-0300 (BRT) <-- started plotting the KML
Started: Tue Mar 29 …Run Code Online (Sandbox Code Playgroud) 我的意思是......让我们只是做一个AJAX请求并在div#result中输入结果.
在后端,脚本使用ob_flush()发送标头但不终止请求,直到它终止(使用exit或ob_flush_end)
只有当请求终止(exit或ob_flush_end)时才会将内容加载到#result中,或者每次脚本通过ob_flush发送标题时都会加载内容?
更新:
我将使用jQuery load()来发出请求和PHP来回答它
这是我的UsersController测试用例:
<?php
App::uses('UsersController', 'Controller');
class TestUsersController extends UsersController {
public $autoRender = false;
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}
public function render($action = null, $layout = null, $file = null) {
$this->renderedAction = $action;
}
public function _stop($status = 0) {
$this->stopped = $status;
}
}
class UsersControllerTestCase extends ControllerTestCase {
public $fixtures = array('app.user');
public function setUp() {
parent::setUp();
$this->Users = new TestUsersController();
$this->Users->constructClasses();
}
public function tearDown() { …Run Code Online (Sandbox Code Playgroud) 最近我安装了Paperclip gem,我正努力让我的系统上的默认图像工作,我把图像文件放在里面assets/images/pic.png.
这是我的模型中的代码User:
has_attached_file :pic,
:styles => { :medium => "300x300>", :thumb => "100x100>" },
:default_url => 'missing_:avatar.png'
#:default_url => 'assets/images/avatar.png'
has_attached_file :attach
Run Code Online (Sandbox Code Playgroud)
这是我AddPicPaperClip迁移中的代码:
def self.up
add_column :users, :pic_file_name, :string
add_column :users, :pic_content_type, :string
add_column :users, :pic_file_size, :integer
add_column :users, :pic_updated_at, :datetime
add_attachment :users, :pic
end
def self.down
remove_column :users, :pic_file_name
remove_column :users, :pic_content_type
remove_column :users, :pic_file_size
remove_column :users, :pic_updated_at
remove_attachment :users, :pic
end
Run Code Online (Sandbox Code Playgroud)
为了在我的节目中显示图像,我有以下代码:
<%= image_tag @user.pic.url(:medium) %>
Run Code Online (Sandbox Code Playgroud)
你可以帮我找一个解决方案,以便在用户输入自己的个人资料图片之前显示默认图片吗?
我正在<select>使用jQuery 创建替换,用div和链接替换它.
现在我想在我开始使用新选择打开键入内容时过滤它.
就像谷歌翻译在语言选择器上做的那样.
你有什么建议我怎么办?
我开始用以下东西:
$(document).bind('keypress', function(event) {
//...
});
Run Code Online (Sandbox Code Playgroud)
但我只捕获单个键,而不是整个键入的字符串.
重要:
<input />检测keypress或keyup事件就可以了<input />因为我只想在"新选择"中使用<div>'s <a>' 和's'有没有办法在自定义帖子类型版页面上插入一个(或多个)上传字段?
我不想在所有的领域和东西中使用midia画廊.
我开始在我的项目中使用virtualenv和virtualenvwrapper.
使用该workon命令激活virtualenv后,我安装了以下软件包pip install -U <package>:
$ lssitepackages
django pip
Django-1.3-py2.7.egg-info pip-1.0.1-py2.7.egg-info
easy-install.pth setuptools-0.6c11-py2.7.egg
fabric setuptools.pth
Fabric-1.0.1-py2.7.egg-info south
geopy South-0.7.3-py2.7.egg-info
geopy-0.94.1-py2.7.egg-info
Run Code Online (Sandbox Code Playgroud)
这里的问题是(运行virtualenv激活的命令):
$ whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.7 /etc/python2.6 /etc/python /etc/python2.7 /usr/lib/python2.6 /usr/lib/python2.7 /usr/lib64/python2.6 /usr/lib64/python2.7 /usr/local/lib/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
$ whereis django-admin
django-admin: /usr/bin/django-admin /usr/local/bin/django-admin.py /usr/share/man/man1/django-admin.1.gz
$ whereis fab
fab: /usr/local/bin/fab
Run Code Online (Sandbox Code Playgroud)
我的virtualenv它没有使用本地包!
我如何强制virtualenv使用本地Python和本地版本的packges而不是我的机器包?
更新 - 可能的解决方案
我创建了一个新的virtualenv,mkvirtualenv --no-site-packages <name>现在我得到了这些输出:
$ which python
/home/user/.virtualenvs/VIRTUALENVNAME/bin/python
$ which django-admin …Run Code Online (Sandbox Code Playgroud) jquery ×3
ajax ×2
django ×2
javascript ×2
admin ×1
cakephp ×1
database ×1
detection ×1
django-admin ×1
git ×1
git-bare ×1
google-maps ×1
keypress ×1
localization ×1
multilingual ×1
mysql ×1
paperclip ×1
path ×1
permissions ×1
php ×1
phpunit ×1
pip ×1
python ×1
ruby ×1
security ×1
string ×1
translation ×1
unit-testing ×1
upload ×1
virtualenv ×1
wordpress ×1