I have gone into a bit of trouble.
I have to call the url of Project 1 from Project 2 views to get the JSON data but when I am trying to call the url using requests it gives me “Max retries exceeded with url” error.
Both the projects are using Django 3 Project 1 is running on port 8001 and the other is on port 8000
Edit: Project 2 is running inside docker container using docker-compose up command and Project 1 is running normally using runserver command.
Please help me out i thought it was a simple task as everything is working fine when doing the same in terminal or python file.
# Project 1
views.py
def send_master_data(request):
return JsonResponse(provide_master_data())
urls.py
path('masterdata/', views.send_master_data, name='send_master_data'),
# Project 2
views.py
@decorators.login_required
def export_master_excel(request):
with requests.Session() as session:
res = session.get("http://127.0.0.1:8001/masterdata/")
data = res.json()
response = HttpResponse(content_type='application/ms-excel')
response['Content-Disposition'] = f'attachment; filename="{data["metadata"]["filename"]}"'
wb = Workbook()