Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with Django templates #4

Open
zerc opened this issue Feb 3, 2021 · 1 comment
Open

Doesn't work with Django templates #4

zerc opened this issue Feb 3, 2021 · 1 comment

Comments

@zerc
Copy link

zerc commented Feb 3, 2021

Hey Alex 馃憢

Recently I've noticed that choices can't be accessed from Django templates i.e. it is possible to access them but an empty string will be returned instead of the value. Here is the snippet to reproduce the problem:

from django.template import engines
from django_better_choices import Choices

from shop.models import Order
from shop.operations.document import render_order_receipt, render_vouchers
from store.models.store import StoreListing

class EXAMPLE(Choices):
    ONE = "The only"

assert EXAMPLE.ONE == 'one'

template = engines['django'].from_string("{{ EXAMPLE.ONE }}")
result = template.render({"EXAMPLE": EXAMPLE})

assert result == 'one', result  # fails, '' != 'one'

Tested with the default template engine.

@lokhman
Copy link
Owner

lokhman commented Mar 26, 2021

Hi Vladimir 馃憢

Cheers for the issue! There is definitely something wrong with my GL notifications. I have noticed your issue only now and no emails were delivered to me. So sorry for the late response!

That's an interesting one, yet no idea why it happens but I will have a look precisely and come back to you.

BTW, did you manage to fix it in your fork or not yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants