Sunday, November 30, 2014

Re: Newbie: How to implement a app/module, which I can include from my html?

Assignment tags are my favorite.

@register.assignment_tag
def get_categories():
   
return Category.objects.all()

{% get_categories as categories %}
{% for category in categories %}
{{ category }}
{% endfor %}

Collin


On Thursday, November 27, 2014 5:19:20 AM UTC-5, somecallitblues wrote:

https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags here you go chief

On 27/11/2014 8:04 pm, "ThomasTheDjangoFan" <stefan.eich...@googlemail.com> wrote:
Oh ok.

so it would be something like:

in home.html
{% include 'category-list.html' %}

in category-lists.html
{% load those_categories %}
<!-- display the categories as html -->

?

Am Donnerstag, 27. November 2014 09:55:50 UTC+1 schrieb James Bennett:
The usual way would be to write a custom template tag that fetches the objects and puts them into the template context.

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d88ef650-0d18-4d6d-bad9-8a6a990524bf%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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9690882c-49da-4ee6-a01b-77270fbc7585%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment