Django Apache serve downloadable images - django

I have a webservices application written in django to which the communication is through andriod app. I have an API call which uploads the images to a media url specified in settings. I have to serve the uploaded files as publicly downloadable files as they will be accessed by the andriod app through API call. This is the reason why I cannot use forms as Django documentation explains. I am using apache to serve my django application through mod_wsgi.
Please help me out on this.

Related

Serving private media files from S3 to single page React App (Django DRF backend)

I have set up an S3 bucket on AWS where I upload my sensitive ‘media’ files from my Django DRF + React app. The files are not public. I use boto3 and Django-storages for that and the upload process works fine. I can also download the files for report generation from backend to return PDF response.
I would now like to display those files one by one from frontend. It seems like I now have two options:
Create a route in Django API/urls to handle media requests and point the app to the media directory. This way, the AWS login is handled by the backend server. This seems to beat the point of using a CDN as all media requests would go via the backend server?
Incorporate login credentials to React front end. This seems insecure.
What would be the recommended way to achieve this? I can’t seem to find the required information.
Thank you.

Where to handle PDF creation in a Django React site

I have a site that uses Django REST framework for the backend, react for the frontend, and axios to handle requests between them.
I want my site to be able to create PDFs for the users. I looked on the web and found that I can create PDFs through both Django and React. I am wondering which one I should use to handle the PDF creation.
It is preferable to handle pdf creation on server side, As for server side you know that system you are using on the server is a powerful system as of you don't know what system your clients will be using also if there is any mobile app develops through that api pdf generated from server side will be compatible else you need to generate pdf for mobile app.
In django you can use xhtmltopdf, wkhtmltopdf to generate pdfs from an html template.

Django REST API as backend and ReactJS as frontend integration

I'm learning ReactJS and I already have experience with Django and DRF. My aim right now is to build a rather simple web application based on a Django backend and a ReactJS frontend. (Later on, when the web app is done, I'll tackle React Native).
I've been reading tons of documentation but nothing has sorted out the question:
What is the best approach to integrate a Django backend with a ReactJS frontend?
Should I keep them separate and connect them or should I mount ReactJS inside the Django application? Which one is the best-suited approach, taking into account maintenance and further development?
Thank you very much! Any opinion/hint will be appreciated.
My approach would be make an app called frontend or anything you like in Django, then all of my React code will be placed inside that app. You will also need webpack to bundle your React code then with collectstatic command Django will collect all the static files so it could be served. You can find the tutorial here

Deploying website along with web application

I'm in the process of researching possible ways to deploy web site along with a web application. I'm using Python/Django with gunicorn as the webserver and AngularJS (front-end) for the web application, which will be deployed on some PaaS like Heroku.
The web site (mainly used for marketing purposes), what are some recommending ways to deploy this site along with the web application? My concern is that users hitting the site will slow down performance for users of the web application. If I'm using Django for the web application backend, is it ok to use Django for the web site and deploy it...say on a different port/server? Perhaps use nginx to serve just static content for the site? What are some best practices out there on solving this? Many thanks
If your "web site" is all static files, could you load it all up into a single folder and have it served directly by nginx?
Alternatively, you could look at something like CloudFlare

Django 1.4 app with django-strage and Amazon S3, using different server serves admin media file

I'm developing django 1.4 app with django-strage, boto and Amazon S3.
And my files for admin is in different server.
In django 1.3, I could use ADMIN_MEDIA_PREFIX, but now it is deprecated.
Do you know how to use admin media file by different server?