Login

Prueba

Author:
hugoxhaal
Posted:
December 17, 2018
Language:
Python
Version:
2.1
Tags:
ajax django python
Score:
0 (after 0 ratings)

Prueba

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class historyView(TemplateView):
    model = Detalle_Venta
    template_name = 'infinitumapp/history.html'
        
    def get(self, request):
        obj = Detalle_Venta.objects.all()
        json = serializers.serialize('json', obj)
        print(json)
        return HttpResponse(json, content_type='application/json')

****************************************************************************************************
<table class="table table-striped table-bordered table-hover" id="example">

    <thead>
        <tr class="text-center">
            <th>ID pedido</th>

        </tr>
    </thead>
    <tbody>

    </tbody>

</table>

<script type="text/javascript">

$(document).ready(function() {
    $('#example').DataTable({
        "processing": true,
        "ajax": {
            "url": "{% url 'history' %}",
            "dataSrc": ""
        },
        "columns": [
            { "data": "pk" },

        ]
    });


});

More like this

Comments

Please login first before commenting.