отображать JSON данные в html с ajax - PullRequest
0 голосов
/ 05 мая 2020

Я хочу отображать JSON данные с html, но это не работает.

js

{% block js %}
      {{ block.super }}
      <script type="text/javascript">
        $(document).ready(function () {
          $.getJSON("{% url 'app_software:list' %}", { get_param: 'value' }, function(data) {
            $.each(data, function(index, element) {
               $('#posts').append(element.title)
            });
        });
      });
      </script>
    {% endblock js %}

html

<div id="posts"></div>

view.py

def home(request):
    ctx={}
    ctx['asd']=Software.objects.all()
    return render(request,'index.html',ctx)

class Pagination_pro(ListAPIView):
    queryset=Software.objects.all()
    serializer_class=pagination_ser
    pagination_class=PageNumberPagination

url.py

urlpatterns = [
    path('', home ,name='home'),
    path('pagination/', Pagination_pro.as_view(), name='list'),
    path('software_detail/<str:slug>/',software2, name='software1'),
]

Нет отображаются ошибки, но он не работает. JSON данные указаны в почтальоне.

...