How can I use django with JSONP to download content from another site?

I have two sites written using Django. I want to upload content from one site to another. I found out that the best choice for this is to use .getJSON and JSON-P , but I don't know how to do it (Django, jQuery and JSONP) together.

Any help from more experienced users?

EDIT

I am trying to achieve a continuous process with things being downloaded from one site to another every time I browse the pages, and not with one dump / loaddata file.

+3
source share
3 answers

. site2 site1. , 2 site1, 2 site1.

- site1 site2 , site2 1, HTTP.

site2 urls.py site1. view2 2 urllib2, HTTP GET POST- 1. view2 site1, .

2 .

def someSite2View( request ):
    site1= urllib2.open( "http://site1/" + request.path  )
    data= site1.read()
    # you have to parse the data to extract the headers
    return Response( headers and data )

. HTTP-.

0

jQuery.ajax(), json- JSONP. , dataType "jsonp" . jsonp. , django-jsonp , , jsonp django.

0

Source: https://habr.com/ru/post/1716262/


All Articles