Re: Custom Template Tag

2016-09-15 Thread 'Abraham Varricatt' via Django users
The idea of doing a POST request during template rendering seems weird. As others have mentioned - that's not the place for it. But perhaps you issue could be a matter of performing your POST operation on the client side, instead of the django server? In that case, it might be worth investigat

Re: Custom Template Tag

2016-09-10 Thread Al Johri
I'm experimenting with creating templates out of subtemplates. These subtemplates can be either (a) simple text or (b) a hash representing a sentence (i.e. {subject: "Dog", verb: "eat", object: "my {{var}}", tense: "past"}). I would like to run the hashes through a realization engine which woul

Re: Custom Template Tag

2016-09-01 Thread Constantine Covtushenko
Hi All, There is no valuable reason to do it in the template. And no matter how to ate using it, cause template should only present view model(s). But if you tell us your intention may be we can suggest a better place for such request? Regards, On Sep 2, 2016 6:03 AM, "Al Johri" wrote: > Ludov

Re: Custom Template Tag

2016-09-01 Thread Al Johri
Ludovic, I'm using the templates for a different purpose, not in a web framework or view. Thanks, Al On Thursday, September 1, 2016 at 8:09:29 AM UTC-4, ludovic coues wrote: > > I wouldn't do it this way. > Personally, I would make the POST request in the view function, put > the return valu

Re: Custom Template Tag

2016-09-01 Thread ludovic coues
I wouldn't do it this way. Personally, I would make the POST request in the view function, put the return value in the context. The template isn't a good place to have logic. It should only take data and format them. 2016-09-01 5:33 GMT+02:00 Al Johri : > Hi Django Users, > > I want to make a cust

Re: Custom template tag problem: "No module named models"

2012-11-08 Thread nolurking
I had the same issue, fixed it with a variation on Jim D.'s solution. import bookmarks then bookmarks.models.Bookmark.objects.filter(...) On Tuesday, October 14, 2008 11:38:20 PM UTC-7, Chris Amico wrote: > > I have a simple bookmarks model based on the one in James Bennett's href="http://code.

Re: custom template tag. success message after form-submit in the same .html file

2011-08-15 Thread Konstantin Sushenko
hello, you can just add a context variable 'submitted' to your context in your view's get_context_data konstantin On Aug 15, 4:06 am, doniyor wrote: > Hi There, > > I am heading well now, but have still some confusing things here.. > > this is my html file, where i want to get a success message

Re: Custom template tag -- Not registered?

2011-04-29 Thread Kenny Meyer
On Fri, Apr 29, 2011 at 5:11 PM, Daniel Roseman wrote: > On Friday, 29 April 2011 21:24:44 UTC+1, Kenny Meyer wrote: >> >> Hello, >> >> I have the following inclusion tag in templatetags/show_submissions.py : >> >> ## BOF >> >> register = template.Library() >> >> @register.inclusion_tag('competiti

Re: Custom template tag -- Not registered?

2011-04-29 Thread Daniel Roseman
On Friday, 29 April 2011 21:24:44 UTC+1, Kenny Meyer wrote: > > Hello, > > I have the following inclusion tag in templatetags/show_submissions.py : > > ## BOF > > register = template.Library() > > @register.inclusion_tag('competition/templatetags/show_submissions.html') > def show_submissions(parti

Re: Custom template tag for a chaptered document?

2010-01-03 Thread Tomasz Zieliński
On 30 Gru 2009, 01:26, Stodge wrote: > I need to write a custom tag. I have a hierarchy of objects that I > want to turn into a chaptered document. But I want to be able to build > and display the document in a template AND generate a PDF or other > format from a view. Can I write a custom templat

Re: Custom template tag problem: "No module named models"

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 8:47 PM, shacker wrote: > > Found the problem. There were no namespace problems in my template > tag, but there were (are) in the external app I'm using, which is the > RSS aggregator used by the djangoproject.com site itself: > > > http://code.djangoproject.com/browser/dja

Re: Custom template tag problem: "No module named models"

2009-10-01 Thread shacker
On Oct 1, 4:00 pm, Karen Tracey wrote: > > Yes, you must simply ensure you name things in such a way that the models > module you want to access is not hidden by something else. The original > problem noted in the thread you reference resulted from re-using the > application's name (bookmarks) a

Re: Custom template tag problem: "No module named models"

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 6:16 PM, shacker wrote: > > Google apparently won't let me reply to an older thread: > > http://groups.google.com/group/django-users/browse_thread/thread/94239f017df4b12f > so starting a new one. > > I too was hitting the "No module named models" problem when creating a > t

Re: Custom Template Tag - Passing variable for use in tag processing

2009-01-29 Thread phoebebright
This is the final code which works in case it helps anyone else. Thanks again. In the template: {% page_links category %} In templatetags file @register.tag(name="page_links") def get_page_links(parser,token): tag_name, category = token.contents.split() return PageLink(cate

Re: Custom Template Tag - Passing variable for use in tag processing

2009-01-29 Thread phoebebright
You understood perfectly. It was just another case of my not understanding the documentation. Your explanation makes perfect sense. Many thanks. On Jan 27, 6:45 pm, Eric Abrahamsen wrote: > On Jan 28, 2009, at 1:52 AM, phoebebright wrote: > > > > > > > I have duplicated as best I can the proc

Re: Custom Template Tag - Passing variable for use in tag processing

2009-01-27 Thread Eric Abrahamsen
On Jan 28, 2009, at 1:52 AM, phoebebright wrote: > > I have duplicated as best I can the processing for handling variables > in custom template tags mentioned in an earlier post but it's not > working for me as I need the value of the variable before I parse it. > Is there another way of making

Re: Custom template tag problem: "No module named models"

2008-11-18 Thread bruno desthuilliers
On 15 oct, 09:19, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-10-15 at 01:08 -0700, bruno desthuilliers wrote: > > [...] > > > FWIW, I just don't understand why each an every example in the > > Django's manual insists on using this projectname.appname scheme. > > "Insists" is a

Re: Custom template tag problem: "No module named models"

2008-11-18 Thread Jim D.
I came across this thread and was having the exact same problem. *Exactly* the same... I had tried everything you tried to no avail. I actually fixed it by taking a hint from something that came out of following along with your debug session in my own code. I'll put my solution in terms of your

Re: Custom Template Tag with {% end... %} tag

2008-10-20 Thread Erik Allik
I guess it was easier for me to type it myself than search through the new documentation. :) Erik On 20.10.2008, at 5:49, James Bennett wrote: > > On Sun, Oct 19, 2008 at 4:20 PM, Erik Allik <[EMAIL PROTECTED]> wrote: >> In the compilation function of your template tag, you can force the >> p

Re: Custom Template Tag with {% end... %} tag

2008-10-19 Thread James Bennett
On Sun, Oct 19, 2008 at 4:20 PM, Erik Allik <[EMAIL PROTECTED]> wrote: > In the compilation function of your template tag, you can force the > parser to parse until tag named "endyourcustomtag" by calling nodelist > = parser.parse(("endyourcustomtag", ). This will return the contents > of your blo

Re: Custom Template Tag with {% end... %} tag

2008-10-19 Thread Siah
Thank you! Sia On Oct 19, 5:20 pm, Erik Allik <[EMAIL PROTECTED]> wrote: > In the compilation function of your template tag, you can force the   > parser to parse until tag named "endyourcustomtag" by calling nodelist   > = parser.parse(("endyourcustomtag", ). This will return the contents   > of

Re: Custom Template Tag with {% end... %} tag

2008-10-19 Thread Erik Allik
In the compilation function of your template tag, you can force the parser to parse until tag named "endyourcustomtag" by calling nodelist = parser.parse(("endyourcustomtag", ). This will return the contents of your block tag as a list of nodes. Finally you can "drop off" the end tag by ca

Re: Custom template tag problem: "No module named models"

2008-10-17 Thread Chris Amico
I think it's fixed now. After much refreshing (I'm editing in Coda) a bookmarks.pyc file appeared. Once that was gone, the tag library did load correctly. I have a different error coming up now, which I'll try to fix or post separately if I can't. Thanks for the help and patience, folks. On Oct

Re: Custom template tag problem: "No module named models"

2008-10-16 Thread Chris Amico
OK, tried all that, got pretty much the same results: >> import bookmarks >>> dir(bookmarks) ['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'models'] >>> bookmarks.__file__ '/home/chrisamico/lib/python2.5/bookmarks/__init__.pyc' >>> from bookmarks import templatetags >>> dir(temp

Re: Custom template tag problem: "No module named models"

2008-10-16 Thread felix
oh well. check that you have an __init__.py file in the templatetags directory try this: in bookmark_tags.py (and do keep the name that way, or later you will be caught by this) right before the import line throw it in into the debugger: import pdb; pdb.set_trace() in the debugger try: >>> i

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread Chris Amico
Tried that. Still no good. I renamed the file as bookmark_tags.py and deleted every .pyc file in the app. Nothing in my templatetags directory actually compiled--neither __init__.py nor bookmarks.py (even after being renamed). Like I said before, when I take out the import line (from bookmarks.mo

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread felix
this gets me every time. the error is yes because the template tag is called bookmarks.py and its inside a module called bookmarks.py rename it to bookmarks_tags.py ... and now DELETE THE DAMNED OLD bookmarks.pyc file ! python is still finding the old compiled file. its happened to me

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread Chris Amico
Wish it were that easy. The app is installed, and it works everywhere else. If I take out the {% load bookmarks %} from the template, the rest of the app works fine. I have a view that bookmarks an object, and it checks if a user has bookmarked that object first. This is how I did it in the view

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread RyanP
Seems like the problem's got to be with the "from bookmarks.models import Bookmark" line. The "No module named models" part of your error message suggests that Django doesn't know about your bookmarks/models.py ... if that app is on your Pyton path, any chance that it's just not listed in your IN

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread Chris Amico
The templatetag file is indeed called bookmarks.py. I thought of that, tried renaming it as bookmark_tags.py, and got the same error. I'll add that the bookmarks app lives on my python path, not in any particular project, since I'm trying to make this as reusable as possible. At one point, I trie

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread Daniel Roseman
On Oct 15, 7:38 am, Chris Amico <[EMAIL PROTECTED]> wrote: > I have a simple bookmarks model based on the one in James Bennett's href="http://code.google.com/p/cab/source/browse/trunk/models.py? > r=130">Cab application. I'm using a generic relation so it can > live in its own app and a user can

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread Malcolm Tredinnick
On Wed, 2008-10-15 at 01:08 -0700, bruno desthuilliers wrote: [...] > FWIW, I just don't understand why each an every example in the > Django's manual insists on using this projectname.appname scheme. "Insists" is a rather strong word, since nowhere does it say "do this or else". Also, out of al

Re: Custom template tag problem: "No module named models"

2008-10-15 Thread bruno desthuilliers
On 15 oct, 08:45, Daniel Roseman <[EMAIL PROTECTED]> wrote: (snip otherwise sound advises) > although I would also > recommend using full paths when importing (ie from > projectname.bookmarks.models). No. *Don't*. If you do so, imports will break when renaming the directory or trying to reuse

Re: Custom template tag

2008-01-13 Thread Alessandro Ronchi
2008/1/13, Alex Koshelev <[EMAIL PROTECTED]>: > > 'templatetags' instead of 'templatetag' > '{% load feed_import %}' instead of '{% load feedimport %}' My error wasn't that (I made a mistake writing here). It was a failed import inside the tag, and that caused the error without the correct error

Re: Custom template tag

2008-01-13 Thread Alex Koshelev
'templatetags' instead of 'templatetag' '{% load feed_import %}' instead of '{% load feedimport %}' On 13 янв, 19:47, Alessandro <[EMAIL PROTECTED]> wrote: > I'm trying to create a custom template tag. I've added a feedimport > app in my project, added it on my installed apps, and inside it I've

Re: Custom template tag

2008-01-13 Thread Alexey Moskvin
The correct directory for your tags is "templatetags", not "templatetag" On 13 янв, 19:47, Alessandro <[EMAIL PROTECTED]> wrote: > I'm trying to create a custom template tag. I've added a feedimport > app in my project, added it on my installed apps, and inside it I've > created a templatetag dir

Re: (solved) Re: Custom template tag and filters in resolve_variable

2007-12-06 Thread Manakel
Nice Nice, i 'll add this to my django reference sheet On Dec 6, 3:34 pm, Empty <[EMAIL PROTECTED]> wrote: > Nice info. This was just asked on the IRC channel a couple nights > ago. I'll be sure to pass it on. > > Michael Trier > blog.michaeltrier.com > > On Dec 5, 2007 7:09 PM, Michal Ludvig <

Re: (solved) Re: Custom template tag and filters in resolve_variable

2007-12-06 Thread Empty
Nice info. This was just asked on the IRC channel a couple nights ago. I'll be sure to pass it on. Michael Trier blog.michaeltrier.com On Dec 5, 2007 7:09 PM, Michal Ludvig <[EMAIL PROTECTED]> wrote: > > Michal Ludvig wrote: > > > for the project I'm working on I needed to create a custom temp

(solved) Re: Custom template tag and filters in resolve_variable

2007-12-05 Thread Michal Ludvig
Michal Ludvig wrote: > for the project I'm working on I needed to create a custom template tag, > call it 'mytag'. > > If I use it as {% mytag something %} everything goes fine (where > 'something' is a string passed to the template). > However I can't add any filters to that 'something'. As soo

Re: Custom template tag and filters in resolve_variable

2007-12-05 Thread Michal Ludvig
Rune Bromer wrote: > On Dec 5, 2007, at 11:59 AM, Michal Ludvig wrote: > >> Hi all, >> >> for the project I'm working on I needed to create a custom template >> tag, >> call it 'mytag'. >> >> If I use it as {% mytag something %} everything goes fine (where >> 'something' is a string passed to t

Re: Custom template tag and filters in resolve_variable

2007-12-05 Thread Rune Bromer
On Dec 5, 2007, at 11:59 AM, Michal Ludvig wrote: > Hi all, > > for the project I'm working on I needed to create a custom template > tag, > call it 'mytag'. > > If I use it as {% mytag something %} everything goes fine (where > 'something' is a string passed to the template). > However I can't

Re: custom template tag

2007-07-06 Thread [EMAIL PROTECTED]
You might want to have a look at this, if not to use it, at least to see how the templatetags are done: http://code.google.com/p/django-template-utils/ On Jul 6, 4:39 pm, dystopia <[EMAIL PROTECTED]> wrote: > Hi, > I've been trying to get something together to > see if I can get to grips with w

Re: Custom Template Tag - What do I need in my actual template?

2006-10-13 Thread MerMer
Tim, Many thanks - that works a treat. I was getting myself very confused about where and how to use the context. Cheers MerMer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to th

Re: Custom Template Tag - What do I need in my actual template?

2006-10-13 Thread Tim Shaffer
Your code looks valid as it is right now. The get_latest_polls function should return a QuerySet of the three latest polls. When you call this function it will get the polls and assign the QuerySet to the "polls" variable for use in your template. In order to display the polls, you would need to

Re: Custom template tag in FlatPage

2006-08-11 Thread Michal
Hello Adrian, thank you for the link to documentation. I was missing __init__.py in my templatetags directory. Have a nice day Michal Adrian Holovaty wrote: > On 8/11/06, Michal <[EMAIL PROTECTED]> wrote: >> Hello, >> I would like use my custom filter function inside Flatpage template. How >> c

Re: Custom template tag in FlatPage

2006-08-11 Thread Adrian Holovaty
On 8/11/06, Michal <[EMAIL PROTECTED]> wrote: > Hello, > I would like use my custom filter function inside Flatpage template. How > could I do this? > > If I try to load my custom tags model ({% load cust_template_tags %}) I > get this error: Hi Michal, A flatpage template is no different from a

Re: Custom template tag (?) help

2006-04-03 Thread Chase
I knew it was something stupid and easy. I was just following the wrong part of the tutorial. Thanks, Chase --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Custom template tag (?) help

2006-04-03 Thread limodou
On 4/4/06, Chase <[EMAIL PROTECTED]> wrote: > > Hi all > > I've read the docs and looked through a few examples, but I can't > figure this out: I want to create the equivalent a global template > variable -- a string representing the current outdoor temperature -- to > display atop every page with