Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Make render_model more compatible with django-hvad #2602

Closed
yakky opened this Issue Feb 9, 2014 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

yakky commented Feb 9, 2014

Using render_model with hvad-translated fields (say {% render_model object 'translated_field' %} return error if the hvad-enabled object does not exists in the current language.
This is documented along with a workaround, but a proper fix is needed

@digi604 digi604 added this to the 3.0 milestone Feb 10, 2014

@digi604 digi604 added the blocker label Mar 18, 2014

Contributor

yakky commented Mar 19, 2014

@digi604 the only solution I can think of is making the templatetag hvad-aware usign something like:

    if hasattr(instance, 'lazy_translation_getter'):
        extra_context['content'] = instance.lazy_translation_getter(attribute, '')
    else:
        extra_context['content'] = getattr(instance, attribute, '')

There is another multilingual implementation that uses the same lazy_translation_getter API as hvad, so we are compatible with it too

Member

digi604 commented Mar 19, 2014

if this fixes the problem: go with it

@digi604 digi604 closed this in #2930 Mar 19, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment