V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
foonpcf
V2EX  ›  Django

django-modeltranslation 怎樣才能支持 zh-tw 及 zh-cn?

  •  
  •   foonpcf · 2013-11-14 16:17:50 +08:00 · 2969 次点击
    这是一个创建于 3817 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我用了以下代碼,在en時能正常運作。而當轉換zh-tw 及 zh-cn就出錯誤.

    ## keyword can't be an expression (<string>, line 1)


    try:
    query = Product.objects.published().select_related()
    product = eval('query.get('
    'slug_'+get_language()+'=slugs[-1],'
    'category__slug_'+get_language()+'=slugs[-2])')
    return render_to_response('products/product.html', {'product':product},
    context_instance=RequestContext(request))
    except: pass

    query = Category.objects.select_related().all()
    category = eval('get_object_or_404(query,'
    'slug_'+get_language()+'=slugs[-1])')
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2988 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:21 · PVG 21:21 · LAX 06:21 · JFK 09:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.