redouane / django-fontawesome

a django app that provides a couple of fontawesome/django related utilities
BSD 2-Clause "Simplified" License
62 stars 74 forks source link

fontawsome tag is not working in templates #5

Closed niranjrajasekaran closed 9 years ago

niranjrajasekaran commented 9 years ago

~python~

Environment:

Request Method: GET Request URL: http://localhost:9900/

Django Version: 1.7.1 Python Version: 2.7.6 Installed Applications: ('grappelli', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'fontawesome', 'bootstrap3', 'website') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Template error: In template /home/niranj/Documents/personal/niranj-website/website/templates/website/index.html, error at line 5 Invalid block tag: 'fontawesome_icon', expected 'endblock' 1 : {% extends 'master.inc' %}

2 :

3 : {% block content %}

4 :

hai

5 : {% fontawesome_icon 'user' %}

6 :

7 :

8 :

9 : {% endblock %}

10 :

11 :

Traceback: File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = wrapped_callback(request, _callback_args, *_callback_kwargs) File "/home/niranj/Documents/personal/niranj-website/website/views.py" in index
  2. return render(request, 'website/index.html', {}) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/shortcuts.py" in render
  3. return HttpResponse(loader.render_to_string(_args, *_kwargs), File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  4. t = get_template(template_name, dirs) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader.py" in get_template
  5. template, origin = find_template(template_name, dirs) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader.py" in find_template
  6. source, display_name = loader(name, dirs) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader.py" in call
  7. return self.load_template(template_name, template_dirs) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader.py" in load_template
  8. template = get_template_from_string(source, origin, template_name) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader.py" in get_template_from_string
  9. return Template(source, origin, name) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/base.py" in init
  10. self.nodelist = compile_string(template_string, origin) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/base.py" in compile_string
  11. return parser.parse() File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/base.py" in parse
  12. compiled_result = compile_func(self, token) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader_tags.py" in do_extends
  13. nodelist = parser.parse() File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/base.py" in parse
  14. compiled_result = compile_func(self, token) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/loader_tags.py" in do_block
  15. nodelist = parser.parse(('endblock',)) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/base.py" in parse
  16. self.invalid_block_tag(token, command, parse_until) File "/home/niranj/Envs/niranj/local/lib/python2.7/site-packages/django/template/base.py" in invalid_block_tag
  17. (command, get_text_list(["'%s'" % p for p in parse_until])))

Exception Type: TemplateSyntaxError at / Exception Value: Invalid block tag: 'fontawesome_icon', expected 'endblock' ~~

redouane commented 9 years ago

hi, did you load the templatetags using {% load fontawesome %} ?

niranjrajasekaran commented 9 years ago

yes i have done it, i have declared {% load fontawesome %} in master and i extended the file in another file, then in the extended block i have used {% fontawesome_icon 'user' %}

niranjrajasekaran commented 9 years ago

I am using django 1.7

redouane commented 9 years ago

well, you need to load it in the child template, not the base one

niranjrajasekaran commented 9 years ago

Thanks @redouane it worked :)