How to use Django and angular together? - django

I've a django backend and angular frontend, on my local machine to use both together, I've to run both server's using ng serve and python manage.py runserver but now I'm planning to deploy it to heroku and I've no idea how will it work, also is there any official guide for using django and angular together.
P.S. - I'm using django-rest-framework for making api calls from frontend to backend.

i never do it before but i think you can do it separately
deploy your django: Heroku django
then deploy your angular app Heroku angular
change your base url to heroku urls
i hope that it would help you :D

Related

Can I dockerize only Django (backend) with React JS (frontend) rendered on same server as Django runs on?

I've developed Django as backend with ReactJS as frontend being served on Django server (127.0.0.1:8000) by putting frontend folder inside backend folder and using static files with path to build/static of frontend in settings.py. So I'm able to run reactjs app on localhost:8000. That's fine.
Now question is if it's possible to dockerize only Django backend, which will have everything including frontend contents and run single docker container opening react js app? Or shall I dockerize frontend as well separately?
Looking forward to your inputs.
Regards
Please note that I've also done with both backend and frontend running separately on 2 servers (localhost:8000 and localhost:3000), used docker-compose to build 2 dockerfiles and them talking each other. So my above q is about possibility to dockerize only backend as a single container image which has frontend static files inside.

Angular django rest framework integration

How to serve angular using Django server?
I don't want to host two different server for angular and Django. How to do it with a single django server?
I have developed frontend application using angular 6 and backend using DRF. I am running django server in the back end and using ng serve command to run angular application.
To achieve this, you should serve your Angular project in production mode. This is a must have if you seriously deploy your project to the world, Angular will optimize the bundle to make UX better than on development mode.
And also for Django project, you should deploy it using gunicorn or uwsgi and using nginx as a reverse proxy (reference this gist) for your application.
Hope that helps!

After deploying django in AWS EB its not working similarly as it runs in localhost

This is how Admin page works in local host
This is how its showing after deploying in AWS EB
can i get help on this like how to get it normal or how to modify it using my own templates please .
In development django itself serves the files, which is not scalable in production, and thus requires you to collect your static files as documented here and serve them using your proxy server.
You can read about how collect static files in django on Elasticbeanstalk here
Before deploying run : python manage.py collectstatic
After running this you should deploy again like you usually do.

Django: Testing locally before pushing app to Heroku

I've followed the instructions from Heroku's "Getting Started with Django", and successfully deployed my application on the Heroku server.
However, there wasn't any tutorial on how to test my application locally before committing and pushing any change on my codes. For example, after I make some minor changes on my css file or Django views, I want to test it on my local computer first, instead of having to do "git push heroku master" every time..
How do I do this with Heroku?
Thanks
To test your app locally you don't need to use Heroku. Simply go to the folder where your manage.py is and do:
python manage.py runserver
It will fire up a development web server with your app you can access using the following URL in your browser: http://localhost:8000.
This web server reloads automatically when you make changes to the Python code. See the Django tutorial: https://docs.djangoproject.com/en/1.7/intro/tutorial01/#the-development-server
Additionally, you might need to set some variables in your environment (export VARNAME=value) to make it work with 12-factor-style settings.

deploy django apps using CherryPy

I want to deploy my django application using CherryPy. But I am looking for a pluggable apps instead of a scripts (which I'll just deploy it via apache)
Any good django apps that do that?
Thanks,
James
django-cpserver