Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Global custom tags
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
diogobaeder  
View profile  
 More options Jul 2, 5:55 pm
From: diogobaeder <diogobae...@gmail.com>
Date: Thu, 2 Jul 2009 14:55:22 -0700 (PDT)
Local: Thurs, Jul 2 2009 5:55 pm
Subject: Global custom tags
Hi there,

Is there a way to create a custom tag that can be used in different
applications at the same time, so that I could make the call on the
"base.html" template? The custom tag, here, is a blog subjects menu,
which I
want to use in all the pages (all the apps) of the website, in the
frontend.

I know that I must create a "templatetags"  subdirectory, to act as a
module, inside the apps, if I want to create a template tag for that
app,
but what if I want to make it visible to all apps and callable from a
base
template?

Thanks!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Buchanan  
View profile  
 More options Jul 2, 8:23 pm
From: Jonathan Buchanan <jonathan.bucha...@gmail.com>
Date: Fri, 3 Jul 2009 01:23:07 +0100
Local: Thurs, Jul 2 2009 8:23 pm
Subject: Re: Global custom tags

If it only needs to be called in the base template, you could just {%
load %} and call it there as normal.

If it really does need to be available globally:

http://www.djangosnippets.org/snippets/160/

Regards,
Jonathan.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
diogobaeder  
View profile  
 More options Jul 2, 10:59 pm
From: diogobaeder <diogobae...@gmail.com>
Date: Thu, 2 Jul 2009 19:59:10 -0700 (PDT)
Local: Thurs, Jul 2 2009 10:59 pm
Subject: Re: Global custom tags
But where do I put the custom template, than? If I load it from an app
template, I must create it under <app>/templatetags/, and what if I
want to call it from the base template? <project_root>/templatetags/?

Thanks!

Diogo

On Jul 2, 9:23 pm, Jonathan Buchanan <jonathan.bucha...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
koenb  
View profile  
 More options Jul 3, 2:10 am
From: koenb <koen.bierm...@werk.belgie.be>
Date: Thu, 2 Jul 2009 23:10:53 -0700 (PDT)
Local: Fri, Jul 3 2009 2:10 am
Subject: Re: Global custom tags
On 3 jul, 04:59, diogobaeder <diogobae...@gmail.com> wrote:

> But where do I put the custom template, than? If I load it from an app
> template, I must create it under <app>/templatetags/, and what if I
> want to call it from the base template? <project_root>/templatetags/?

> Thanks!

> Diogo

I think you are missing something here: there really is no app
namespacing in templatetags: if you try to load a tag library, django
will search the templatetags folders located underneath all installed
apps. If it finds one that matches, it will use that one. This means
that you can use a tag library from app X in any template you use (no
matter where it is located), as long as app X is in the installed
apps. The downside of this is that you need to name your tag libraries
wisely, because tags.py in app X and tags.py in app Y will conflict.

Koen


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
diogobaeder  
View profile  
 More options Jul 3, 2:56 pm
From: diogobaeder <diogobae...@gmail.com>
Date: Fri, 3 Jul 2009 11:56:48 -0700 (PDT)
Local: Fri, Jul 3 2009 2:56 pm
Subject: Re: Global custom tags
Great, koenb, now its getting even clearer to me! :-)

Thanks for the light,

Diogo

On Jul 3, 3:10 am, koenb <koen.bierm...@werk.belgie.be> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
diogobaeder  
View profile  
 More options Jul 4, 11:51 pm
From: diogobaeder <diogobae...@gmail.com>
Date: Sat, 4 Jul 2009 20:51:42 -0700 (PDT)
Local: Sat, Jul 4 2009 11:51 pm
Subject: Re: Global custom tags
Koen,

I tried to make an initial template tag, just to test and learn, but
it's not working. I followed the instructions here
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howt...
and registered the compilation function, but it's not finding the
module, like stated here in this stack trace, even though I've saved
the _init_.py file:
http://dpaste.com/63306/

The code I used to test it is here:
http://dpaste.com/63308/

Any ideas?

Thanks again!

Diogo

On Jul 3, 3:10 am, koenb <koen.bierm...@werk.belgie.be> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ronghui Yu  
View profile  
 More options Jul 5, 5:32 am
From: Ronghui Yu <stone...@gmail.com>
Date: Sun, 05 Jul 2009 17:32:22 +0800
Local: Sun, Jul 5 2009 5:32 am
Subject: Re: Global custom tags

_init_.py should be

__init__.py

or just a typo error in the mail?

diogobaeder ??:

--
Ronghui Yu <mailto:stone...@163.com>

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
diogobaeder  
View profile  
 More options Jul 5, 12:09 pm
From: diogobaeder <diogobae...@gmail.com>
Date: Sun, 5 Jul 2009 09:09:00 -0700 (PDT)
Subject: Re: Global custom tags
Thanks, Yu, it was a lack of attention of mine, not just a typo... I
corrected the file name, now the module is being found, thanks! :-)

Diogo

On Jul 5, 6:32 am, Ronghui Yu <stone...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
diogobaeder  
View profile  
 More options Jul 6, 3:46 am
From: diogobaeder <diogobae...@gmail.com>
Date: Mon, 6 Jul 2009 00:46:22 -0700 (PDT)
Local: Mon, Jul 6 2009 3:46 am
Subject: Re: Global custom tags
Great, guys! Solved! Now I have a global custom tag for recursive
nested list in all the views! Nice! :-)

Next step: see if my hosting privider has python-memcache to put these
guys under a cache... doesn't sound nice to have these repeated
queries on a bank, considering they won't change so much... :-P

Thanks for the help, guys! Thread solved!

Diogo

On Jul 5, 1:09 pm, diogobaeder <diogobae...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google