Thanks! great advice. I am going to try to pass the data from the
view.

On Oct 13, 2:56 pm, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 13 oct, 20:59, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Hello,
>
> > I want to return a context of data to the template
>
> I assume you mean "pass", not "return".
>
> > that contains
> > information in the models. I want to pass in variables that dictate
> > what is returned.
>
> > Example:
> > author1.get_books_published_after <some_date>
> > Then it grabs all the data via a method in the model and returns it.
>
> Won't work. Django's template language is *not* Python, it's a
> language on it's own.
>
> > Should I instead use the custom template tags?
>
> This might be a solution, yes. But why not just populate your context
> with relevant data, ie:
>
> def myview(request, yadda):
>   author = get_author_someway()
>   date = get_date_somehow()
>   books = author.get_books_published_after(date)
>   context = dict(author=author, date=date, books=books)
>   return render_to_response("mytemplate.html", context)
>
> > Then the call would be like so??
>
> For a template tag ? Well, since you'll have to implement it by
> yourself, the syntax is up to you. But just for the record, an
> emerging convention for template tags that "insert" additional data in
> the context is to end them with " as <varname>" to let the caller
> specify the name under which the data must be known in the template.
>
> > Example:
> > get_books_published_after <author> <some_date>
> > Then it would return all the books for the author that was published
> > after a certain date.
>
> I'd suggest:
>
> {% get_books_published for <author> after <some_date> as <some_name>
> %}
>
> Now you just have to write the compilation function and rendering
> Node. Relevant doc is here:
>
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writ...
>
> Please feel free to come back here with more questions *once* you'll
> have read the doc and started to write your custom tag - we'll be glad
> to help further. Until then, anything I could add is already explained
> in the doc.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to