Hi,

You don't need the {{}} when sending a variable to the template tag - try
removing them.

Regards,

Andréas


Den ons 22 aug. 2018 kl 12:17 skrev MikeKJ <mike.jo...@paston.co.uk>:

>
> I am so rusty I’m having trouble writing a simple_tag
>
>
>
> In the template
>
>
>
> {% for b in list %}
>
> {% load get_cost %}{% do_cost {{ b.name }} avn avd %}
>
>
>
> Also tried (per docs) {% do_cost name={{ b.name }} avn=avn avd=avd %}
>
> I definitely have values in the template passed from the view for avn and
> avd and of course b.name
>
>
>
> Tag
>
> from django import template
>
> from django.conf import settings
>
> from django.utils.html import escape
>
> from band.models import Data
>
>
>
> register = template.Library()
>
>
>
> @register.simple_tag
>
> def do_cost( name, avn, avd, *args, **kwargs ):
>
>     avn = kwargs['avn']
>
>     avd = kwargs['avd']
>
>     name = kwargs['name']
>
>
>
>     val = Data.objects.filter(property=name).filter(date_period=date)
>
>     return val
>
>
>
> I just keep getting do_cost takes 3 arguments
>
> *** I know I want it to take 3 arguments!!!!***
>
> Is it telling me that I can’t use {{ b.name }} as an arg?
>
>
> --
> 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/de8c0f7e-c8ee-4329-a954-457acfd01c64%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/de8c0f7e-c8ee-4329-a954-457acfd01c64%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAK4qSCdcjnzhxoeLhpMsaSLbR0e7tHMtWp%2Bkczd9hyMr8e81_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to