You need to write a template tag 
<https://docs.djangoproject.com/en/2.0/howto/custom-template-tags/>which 
will make use of the num2words 
<https://pypi.python.org/pypi/num2words/0.5.6> library to convert the cash 
to words and apply it in your template.

Lets say your template tag name is *num2word*, You can apply it in your 
template like 
*{{ payment.cash|num2word }}*




On Sunday, 28 January 2018 22:02:54 UTC+5:30, Ariel Matysiak wrote:
>
> Hello :)
>
> It's my first post in here.
>
> I've made simple model and simple app.
>
> I want to use num2words library and I want to see my "cash" i words.
>
> I don't know how to do it/
>
> Can you help me ???
>
> Please edit code for me.
>
>
> -------------------------------------------
> models.py
>
> class Payment(models.Model):
>     name = models.CharField(max_length=20)
>     cash = models.IntegerField()
>
>     def __str__(self):
>         return self.name
> ------------------------------------------------
> views.py
>
> class PaymentListView(ListView):
>     model = Payment
>
> ---------------------------------------------
> template.html
>
> {% for payment in payment_list %}
>             <p>{{ payment.name }}: {{ payment.cash }}</p>
> {% endfor %}
>
> -----------------------------------------------
> forms.py
>
> class PaymentForm(forms.ModelForm):
>
>     class Meta:
>         model = Payment
>         fields = ('name','cash')
>
>
> THANK YOU VERY MUCH
> Ariel
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb338c90-57da-4bb2-9693-3d8843ba3642%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to