Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Fullcalendar error rendering Unexpected token

Going through a new django 3 project, newbie on that, so sorry me if my code is not so clean. The problem is when i try to render calendar... without events it loads nicely, but when loading'em it stops rendering the whole calendar. Console throes an Uncaught SyntaxError: Unexpected token '{', but i can´t find the problem, neither is a comma into my loop. Any help welcome. My calendar script:

<script>
    document.addEventListener('DOMContentLoaded', function () {
        var cUI = document.getElementById('calendar');
        var c = new FullCalendar.Calendar(cUI, {
            themeSystem: 'bootstrap',
            headerToolbar: {
                left: 'prev,next today',
                center: 'title',
                right: '',
            },
            events: {
            {% for v in vacation %}
                {
                    title: "{{ v.reason }}: {{ v.starth }}-{{ v.endh }}",
                    start: "{{ v.start | date:'Y-m-d' }}",
                    end: "{{ v.end | date:'Y-m-d' }}",
                },
            {% endfor %}
            },
        });
        c.render();
        c.setOption('locale', 'es');
    });
</script>

Thank you

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The syntax error you've made is in the events object. Because it is a javascript object, it expects key-value entries. That means you need to provide keys for your items:

events: { // <-- the `{` shows that events is an object
    keyOne: { // <-- items in objects need keys (such as `keyOne`)
        title: "{{ v.reason }}: {{ v.starth }}-{{ v.endh }}",
        start: "{{ v.start | date:'Y-m-d' }}",
        end: "{{ v.end | date:'Y-m-d' }}",
    },
    keyTwo: {
        title: "{{ v.reason }}: {{ v.starth }}-{{ v.endh }}",
        start: "{{ v.start | date:'Y-m-d' }}",
        end: "{{ v.end | date:'Y-m-d' }}",
    },
},

Now, if you just wanted to list these objects inside a "variable" called events, then it should be an array:

events: [ // <-- the `[` shows that events is an array
    { // <-- items in arrays do not need keys
        title: "{{ v.reason }}: {{ v.starth }}-{{ v.endh }}",
        start: "{{ v.start | date:'Y-m-d' }}",
        end: "{{ v.end | date:'Y-m-d' }}",
    },
    {
        title: "{{ v.reason }}: {{ v.starth }}-{{ v.endh }}",
        start: "{{ v.start | date:'Y-m-d' }}",
        end: "{{ v.end | date:'Y-m-d' }}",
    },
},
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!