foonpcf
V2EX  ›  Django

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

  •  
  •   foonpcf · Nov 14, 2013 · 3786 views
    This topic created in 4588 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   ·   1192 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 23:44 · PVG 07:44 · LAX 16:44 · JFK 19:44
    ♥ Do have faith in what you're doing.