0

I have datatables set up according to how it explains on the site

This is my base.html

<!DOCTYPE html>
{% load static %}
<head>
    <link href="{% static 'tickets/css/bootstrap.min.css' %}" rel="stylesheet" media="screen" >
    <link href="{% static 'tickets/css/styles.css' %}" rel="stylesheet" >
    <link rel="stylesheet" type="text/css" href="{% static 'tickets/DataTables-1.10.8/media/css/jquery.dataTables.css'  %}">

    <script type="text/javascript" charset="utf8" src="{% static  'tickets/DataTables-1.10.8/media/js/jquery.js' %}"></script>
    <script type="text/javascript" charset="utf8" src"{% static 'tickets/Datatables-1.10.8/media/js/jquery.dataTables.js' %}"></script>

<title>{% block title %}VGTSI Tickets {% endblock %} </title>

<script type="text/javascript" class="init">

    $(document).ready( function ($) {
        $('#table_id').DataTable();

    });


</script>

</head>

This is the table for datatables

<table id="table_id" class="display">
    <thead>
        <tr>
            <th>Title</th><th>Date</th><th>Open/Closed</th>
        </tr>
    </thead>
    <tbody>
    {% for ticket in ticket_list %}
    <tr>
        <td><a href="{% url 'tickets:view_ticket' ticket.id %}">{{ticket.title}}</a></td>   
        <td>{{ticket.dateOfIssue}}</td>              
        <td>{{ticket.resolved}}</td>
    </tr>
    {% endfor %}
    </tbody>
</table>

And the view

@login_required
def view_all(request):
    ticket_list = Ticket.objects.order_by('dateOfIssue')[:20]
    context = {'ticket_list' : ticket_list}
    return render(request, 'tickets/view_all.html', context)

After looking in the console on firebug the error I get is TypeError: $(...).DataTable is not a function I've looked at other questions on this site with similar problems but none of their solutions have worked. Is it something obvious? Please help.

1 Answer 1

1

You are missing an equal sign (=) in this line (right after src):

<script type="text/javascript" charset="utf8" src"{% static 'tickets/Datatables-1.10.8/media/js/jquery.dataTables.js' %}"></script>

Fixed:

<script type="text/javascript" charset="utf8" src="{% static 'tickets/Datatables-1.10.8/media/js/jquery.dataTables.js' %}"></script>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Something so small I didn't notice it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.