Image Not Loading. "TemplateSyntaxerror"

198 views
Skip to first unread message

Daniyal Chawla

unread,
May 17, 2021, 3:28:04 PM5/17/21
to oTree help & discussion
Hi team, 

I have been trying to load an image, but the code below gives me the TemplateSyntaxerror: Could not parse the remainder: ' 'grading_app/thirty.jpg'' from 'static 'grading_app/thirty.jpg'' when I run it:

{% extends "global/Page.html" %}
{% load otree %}

{% block content %}

    <h2>Image Should Go Here</h2>
    <img src=" static 'grading_app/thirty.jpg' "/>

    {% formfields %}
    <p>
    {% next_button %}
    </p>

{% endblock %}

I am sure the folder and image names are correct. I tried getting rid of the quotation marks, replacing that line with <img src=" static 'grading_app/thirty.jpg' "/> . This got rid of the TemplateSyntaxError, but I ended up seeing just the icon below (instead of the actual image):

Screenshot (68).png

Thanks in advance!!

Chris Crabbe

unread,
May 17, 2021, 4:08:25 PM5/17/21
to Daniyal Chawla, oTree help & discussion
Hi Daniyal -

It doesn't look quite like you're using the correct syntax in your template for static files - you're missing the curly brackets needed for a template tag:


That page is for oTree5 syntax - if you're using otree<5, make sure to switch over to the other version of the documentation.

Thanks,
--Chris

--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/d5124a40-698e-47d5-8dfb-e9aa743b6ff6n%40googlegroups.com.

Daniyal Chawla

unread,
May 18, 2021, 4:53:32 AM5/18/21
to Chris Crabbe, oTree help & discussion
Awesome, thank you so much! It worked. You were right, I was using otree<3 but trying to follow the documentation for the oTree5. Thanks, have a great day!
Reply all
Reply to author
Forward
0 new messages