template tag help please?

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

template tag help please?

MikeKJ
I want to pass 2 variables to a templatetag from within a template, a name and a date (eg, John 29/09/2018) to output the result of the templatetag def.

The reason I want to do this is:

From a list of all names:

The name comes from a model that has a foreign key to another model that has actions performed by that name by date and I want to output the action taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
    action = Data.objects.get.filter(person=name).filter(date=date)
    return action

but how do I pass the variables in the 1st place please?


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Mikhailo Keda
Check the documentation - https://docs.djangoproject.com/ko/2.1/howto/custom-template-tags/

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/553d2ac6-cac1-4b9a-b3bd-2a4f5934ae47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: template tag help please?

MikeKJ

Yes

 

For example, in the filter {{ var|foo:"bar" }}, the filter foo would be passed the variable var and the argument "bar".

 

I want to pass 2 (maybe 3) variables and correct me if I am wrong but

Custom filters are just Python functions that take one or two arguments:

 

So could do  {{ var|foo:”bar, bar2” }}

or {{ var|foo:”bar” “bar2” }}   and pass 2 arguments?   The doc doesn’t specify

 

I assume if 2 args

def cut(value, arg1, arg2):

 

?

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mikhailo Keda
Sent: 17 August 2018 14:43
To: Django users
Subject: Re: template tag help please?

 

Check the documentation - https://docs.djangoproject.com/ko/2.1/howto/custom-template-tags/

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
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/553d2ac6-cac1-4b9a-b3bd-2a4f5934ae47%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/5b76d50e.1c69fb81.ad6af.0d3eSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

MikeKJ
In reply to this post by Mikhailo Keda

Yes

 

For example, in the filter {{ var|foo:"bar" }}, the filter foo would be passed the variable var and the argument "bar".

 

I want to pass 2 (maybe 3) variables and correct me if I am wrong but

Custom filters are just Python functions that take one or two arguments:

 

So could do  {{ var|foo:”bar, bar2” }}

or {{ var|foo:”bar” “bar2” }}   and pass 2 arguments?   The doc doesn’t specify

 

I assume if 2 args

def cut(value, arg1, arg2):

 

?



--
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 [hidden email].
To post to this group, send email to [hidden email].
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/e81d25fc-977c-47cd-84bf-ed65b2091391%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Mikhailo Keda
In reply to this post by MikeKJ
"Then in the template any number of arguments, separated by spaces, may be passed to the template tag." from the Documentation

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/39e03641-064f-416f-88a8-bf4198854924%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

MikeKJ
In reply to this post by MikeKJ

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 [hidden email].
To post to this group, send email to [hidden email].
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.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Andréas Kühne
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 <[hidden email]>:

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 [hidden email].
To post to this group, send email to [hidden email].
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.
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 [hidden email].
To post to this group, send email to [hidden email].
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 | Threaded
Open this post in threaded view
|

Re: template tag help please?

MikeKJ
In reply to this post by MikeKJ

Thank you Andreas Kuhne, progress

So this {% load get_cost %}{% do_cost b.name avn avd %} is not getting any error on the template but as simple as the below is there is no return

from django import template
from django.conf import settings
from django.utils.html import escape
register = template.Library()

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    avn = kwargs['avn']
    avd = kwargs['avd']
    name = kwargs['name']
    return name


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/76f303e0-84b4-4042-aad3-93e18bbfb863%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

MikeKJ
In reply to this post by MikeKJ

Thank you Andreas Kuhne, progress

 

So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite happily but for some reason is now complaining

Exception Type: TemplateSyntaxError
 Exception Value:
Caught KeyError while rendering: 'avn'

Exception Location claims to be    get_cost.py in do_cost, line 10  which is avn = kwargs['avn']

but the exception is in the template line {% load get_cost %}{% do_cost b.name avn avd %}



--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Andréas Kühne
Wait a secound, you are doing some very strange things....

I didn't see this before.

You have defined the following:
@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    avn = kwargs['avn']
    avd = kwargs['avd']
    name = kwargs['name']
    return name

The method has 3 parameters that you are sending to it - name, avn and avd. They correspond to the values sent to the method in order. So you don't need to use the kwargs dictionary - it's unnecessary...

You could just write:
@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    return name

Beacause you have sent the name to the method?

Regards,

Andréas


Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ <[hidden email]>:

Thank you Andreas Kuhne, progress

 

So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite happily but for some reason is now complaining

Exception Type: TemplateSyntaxError
 Exception Value:
Caught KeyError while rendering: 'avn'

Exception Location claims to be    get_cost.py in do_cost, line 10  which is avn = kwargs['avn']

but the exception is in the template line {% load get_cost %}{% do_cost b.name avn avd %}



--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: template tag help please?

MikeKJ

Ah I was just doing that to prove it was working

 

This is the actual 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_set = Data.objects.filter(prop = name).filter(date_period=avd)

    avn = 7  #this line is just for testing

    if avn >= 7:

        for x in val_set:

            val = x.full

    else:

        for x in val_set:

            val = x.short

    return val

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Andréas Kühne
Sent: 22 August 2018 15:20
To: [hidden email]
Subject: Re: template tag help please?

 

Wait a secound, you are doing some very strange things....

 

I didn't see this before.

 

You have defined the following:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    avn = kwargs['avn']
    avd = kwargs['avd']
    name = kwargs['name']
    return name

 

The method has 3 parameters that you are sending to it - name, avn and avd. They correspond to the values sent to the method in order. So you don't need to use the kwargs dictionary - it's unnecessary...

You could just write:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    return name


Beacause you have sent the name to the method?

 

Regards,

 

Andréas

 

 

Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ <[hidden email]>:

Thank you Andreas Kuhne, progress

 

So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite happily but for some reason is now complaining

 

Exception Type:

TemplateSyntaxError

 Exception Value:

Caught KeyError while rendering: 'avn'

 

Exception Location claims to be    get_cost.py in do_cost, line 10  which is avn = kwargs['avn']

 

but the exception is in the template line {% load get_cost %}{% do_cost b.name avn avd %}

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
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/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/5b7d7953.1c69fb81.85c08.097dSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Mikhailo Keda
In reply to this post by Andréas Kühne
Probably you don't need template tag at all, try {{ b.name }}
if you just need to get name value from b

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/fc0cedda-78ae-484b-837b-9eb990ab1d2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Andréas Kühne
In reply to this post by MikeKJ
Yes - but you still are doing it strange - you shouldn't use kwargs if you are sending the parameters and have the parameters in the function - use the parameters.

In other words: 

    avn = kwargs['avn']

    avd = kwargs['avd']

    name = kwargs['name']


That is unnecessary....


Regards,

Andréas


Den ons 22 aug. 2018 kl 16:55 skrev Mike Jones <[hidden email]>:

Ah I was just doing that to prove it was working

 

This is the actual 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_set = Data.objects.filter(prop = name).filter(date_period=avd)

    avn = 7  #this line is just for testing

    if avn >= 7:

        for x in val_set:

            val = x.full

    else:

        for x in val_set:

            val = x.short

    return val

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Andréas Kühne
Sent: 22 August 2018 15:20
To: [hidden email]
Subject: Re: template tag help please?

 

Wait a secound, you are doing some very strange things....

 

I didn't see this before.

 

You have defined the following:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    avn = kwargs['avn']
    avd = kwargs['avd']
    name = kwargs['name']
    return name

 

The method has 3 parameters that you are sending to it - name, avn and avd. They correspond to the values sent to the method in order. So you don't need to use the kwargs dictionary - it's unnecessary...

You could just write:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    return name


Beacause you have sent the name to the method?

 

Regards,

 

Andréas

 

 

Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ <[hidden email]>:

Thank you Andreas Kuhne, progress

 

So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite happily but for some reason is now complaining

 

Exception Type:

TemplateSyntaxError

 Exception Value:

Caught KeyError while rendering: 'avn'

 

Exception Location claims to be    get_cost.py in do_cost, line 10  which is avn = kwargs['avn']

 

but the exception is in the template line {% load get_cost %}{% do_cost b.name avn avd %}

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
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/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/5b7d7953.1c69fb81.85c08.097dSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAK4qSCcbeyp%2B33YCNmK6w053X14-4Noqxm2KWPj58A-rs8EJrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: template tag help please?

MikeKJ

Andreas, 

Thank you for your help and patience I have got the damned thing working!! 

It helped that I remembered that one of the filter arguments was actually a foreign key in the model and had to be an integer id not a string,  that was being obfuscated by being a templatetag call.

 

Thank you

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Andréas Kühne
Sent: 23 August 2018 08:15
To: [hidden email]
Subject: Re: template tag help please?

 

Yes - but you still are doing it strange - you shouldn't use kwargs if you are sending the parameters and have the parameters in the function - use the parameters.

 

In other words: 

    avn = kwargs['avn']

    avd = kwargs['avd']

    name = kwargs['name']

 

That is unnecessary....


Regards,

 

Andréas

 

 

Den ons 22 aug. 2018 kl 16:55 skrev Mike Jones <[hidden email]>:

Ah I was just doing that to prove it was working

 

This is the actual 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_set = Data.objects.filter(prop = name).filter(date_period=avd)

    avn = 7  #this line is just for testing

    if avn >= 7:

        for x in val_set:

            val = x.full

    else:

        for x in val_set:

            val = x.short

    return val

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Andréas Kühne
Sent: 22 August 2018 15:20
To: [hidden email]
Subject: Re: template tag help please?

 

Wait a secound, you are doing some very strange things....

 

I didn't see this before.

 

You have defined the following:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    avn = kwargs['avn']
    avd = kwargs['avd']
    name = kwargs['name']
    return name

 

The method has 3 parameters that you are sending to it - name, avn and avd. They correspond to the values sent to the method in order. So you don't need to use the kwargs dictionary - it's unnecessary...

You could just write:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
    return name


Beacause you have sent the name to the method?

 

Regards,

 

Andréas

 

 

Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ <[hidden email]>:

Thank you Andreas Kuhne, progress

 

So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite happily but for some reason is now complaining

 

Exception Type:

TemplateSyntaxError

 Exception Value:

Caught KeyError while rendering: 'avn'

 

Exception Location claims to be    get_cost.py in do_cost, line 10  which is avn = kwargs['avn']

 

but the exception is in the template line {% load get_cost %}{% do_cost b.name avn avd %}

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
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/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/5b7d7953.1c69fb81.85c08.097dSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
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/CAK4qSCcbeyp%2B33YCNmK6w053X14-4Noqxm2KWPj58A-rs8EJrA%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/5b7e81c5.1c69fb81.37bbe.188eSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Tosin Ayoola
In reply to this post by MikeKJ
good day please i'm having issues, attached below is one of the error i'm getting also ive been trying to add bootstrap glyphicon to my project but it just display the text without the glyphicon,

On Fri, Aug 17, 2018 at 12:54 PM MikeKJ <[hidden email]> wrote:
I want to pass 2 variables to a templatetag from within a template, a name and a date (eg, John 29/09/2018) to output the result of the templatetag def.

The reason I want to do this is:

From a list of all names:

The name comes from a model that has a foreign key to another model that has actions performed by that name by date and I want to output the action taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
    action = Data.objects.get.filter(person=name).filter(date=date)
    return action

but how do I pass the variables in the 1st place please?


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Screenshot from 2018-08-23 13-50-27.png (218K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

ireoluwa fakeye
You Are not properly routing your  urls

On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, <[hidden email]> wrote:
good day please i'm having issues, attached below is one of the error i'm getting also ive been trying to add bootstrap glyphicon to my project but it just display the text without the glyphicon,

On Fri, Aug 17, 2018 at 12:54 PM MikeKJ <[hidden email]> wrote:
I want to pass 2 variables to a templatetag from within a template, a name and a date (eg, John 29/09/2018) to output the result of the templatetag def.

The reason I want to do this is:

From a list of all names:

The name comes from a model that has a foreign key to another model that has actions performed by that name by date and I want to output the action taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
    action = Data.objects.get.filter(person=name).filter(date=date)
    return action

but how do I pass the variables in the 1st place please?


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Tosin Ayoola
not properly routing my urls as in, i don't understand

On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye <[hidden email]> wrote:
You Are not properly routing your  urls

On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, <[hidden email]> wrote:
good day please i'm having issues, attached below is one of the error i'm getting also ive been trying to add bootstrap glyphicon to my project but it just display the text without the glyphicon,

On Fri, Aug 17, 2018 at 12:54 PM MikeKJ <[hidden email]> wrote:
I want to pass 2 variables to a templatetag from within a template, a name and a date (eg, John 29/09/2018) to output the result of the templatetag def.

The reason I want to do this is:

From a list of all names:

The name comes from a model that has a foreign key to another model that has actions performed by that name by date and I want to output the action taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
    action = Data.objects.get.filter(person=name).filter(date=date)
    return action

but how do I pass the variables in the 1st place please?


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

ireoluwa fakeye
Sorry didn't look at it well ,can I see a screen shot of your code

On Thu, 23 Aug 2018, 14:10 Tosin Ayoola, <[hidden email]> wrote:
not properly routing my urls as in, i don't understand

On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye <[hidden email]> wrote:
You Are not properly routing your  urls

On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, <[hidden email]> wrote:
good day please i'm having issues, attached below is one of the error i'm getting also ive been trying to add bootstrap glyphicon to my project but it just display the text without the glyphicon,

On Fri, Aug 17, 2018 at 12:54 PM MikeKJ <[hidden email]> wrote:
I want to pass 2 variables to a templatetag from within a template, a name and a date (eg, John 29/09/2018) to output the result of the templatetag def.

The reason I want to do this is:

From a list of all names:

The name comes from a model that has a foreign key to another model that has actions performed by that name by date and I want to output the action taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
    action = Data.objects.get.filter(person=name).filter(date=date)
    return action

but how do I pass the variables in the 1st place please?


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g10CtF%3Dj7C5ZbGYSKX1J7DFRNPDgfbLBAwNVXhWYPmdS0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Tosin Ayoola
i have the code on git actually because i'm trying to get the add a file at the admin page but i'm getting the error


On Thu, Aug 23, 2018 at 2:17 PM ireoluwa fakeye <[hidden email]> wrote:
Sorry didn't look at it well ,can I see a screen shot of your code

On Thu, 23 Aug 2018, 14:10 Tosin Ayoola, <[hidden email]> wrote:
not properly routing my urls as in, i don't understand

On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye <[hidden email]> wrote:
You Are not properly routing your  urls

On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, <[hidden email]> wrote:
good day please i'm having issues, attached below is one of the error i'm getting also ive been trying to add bootstrap glyphicon to my project but it just display the text without the glyphicon,

On Fri, Aug 17, 2018 at 12:54 PM MikeKJ <[hidden email]> wrote:
I want to pass 2 variables to a templatetag from within a template, a name and a date (eg, John 29/09/2018) to output the result of the templatetag def.

The reason I want to do this is:

From a list of all names:

The name comes from a model that has a foreign key to another model that has actions performed by that name by date and I want to output the action taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
    action = Data.objects.get.filter(person=name).filter(date=date)
    return action

but how do I pass the variables in the 1st place please?


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g10CtF%3Dj7C5ZbGYSKX1J7DFRNPDgfbLBAwNVXhWYPmdS0w%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn70wySpx9bVG3BvBsZ-egY9Gsm%2Bt0jEgGSkxwFUtA_G%2B_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: template tag help please?

Tosin Ayoola
this is the link https://github.com/olaneat/ask_the_schools will rili b glad if u can help


On Thu, Aug 23, 2018 at 2:31 PM Tosin Ayoola <[hidden email]> wrote:
i have the code on git actually because i'm trying to get the add a file at the admin page but i'm getting the error


On Thu, Aug 23, 2018 at 2:17 PM ireoluwa fakeye <[hidden email]> wrote:
Sorry didn't look at it well ,can I see a screen shot of your code

On Thu, 23 Aug 2018, 14:10 Tosin Ayoola, <[hidden email]> wrote:
not properly routing my urls as in, i don't understand

On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye <[hidden email]> wrote:
You Are not properly routing your  urls

On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, <[hidden email]> wrote:
good day please i'm having issues, attached below is one of the error i'm getting also ive been trying to add bootstrap glyphicon to my project but it just display the text without the glyphicon,

On Fri, Aug 17, 2018 at 12:54 PM MikeKJ <[hidden email]> wrote:
I want to pass 2 variables to a templatetag from within a template, a name and a date (eg, John 29/09/2018) to output the result of the templatetag def.

The reason I want to do this is:

From a list of all names:

The name comes from a model that has a foreign key to another model that has actions performed by that name by date and I want to output the action taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
    action = Data.objects.get.filter(person=name).filter(date=date)
    return action

but how do I pass the variables in the 1st place please?


--
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 [hidden email].
To post to this group, send email to [hidden email].
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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAO87g10CtF%3Dj7C5ZbGYSKX1J7DFRNPDgfbLBAwNVXhWYPmdS0w%40mail.gmail.com.
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAHLKn73VtUomf5YWYbATXwp88duA74ujhmvC35CiumDnzkuznw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
12