V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
foonpcf
V2EX  ›  Django

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

  •  
  •   foonpcf · Nov 14, 2013 · 3728 views
    This topic created in 4559 days ago, the information mentioned may be changed or developed.
    我用了以下代碼,在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])')
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4647 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 10:04 · PVG 18:04 · LAX 03:04 · JFK 06:04
    ♥ Do have faith in what you're doing.