Reputation: 4692
I wanna use templatetags of contrib.admin
in Djnago
. To do this added required things to INSTALLED_APPS
in settings.py.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
...
)
But when I try to use one of the tags, it says Invalid block tag: 'x'
. I tried to use 'search_form'
and 'admin_list_filter'
tags and I saw the error for them.
{% block search %}{% search_form cl %}{% endblock %}
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
What may I be missing?
Thank You
Upvotes: 2
Views: 2165
Reputation: 309019
The template tags from the Django admin are not really re-usable. To use the search_form
tag, you would have to provide a ChangeList
instance, which is very tightly coupled to the Django admin.
If you were able to reuse the tag, you would have to load the tag library first.
The search_form
tag is in django.contrib.admin.templatetags.admin_list
. Therefore, you would have to load the admin_list
tags before could use it.
{% load admin_list %}
{% search_form cl %}
Upvotes: 2