Monolithic Django and React.js: Tips and Tricks

JOY SAM RAJJOY SAM RAJ
2 min read

In early stage of startup we use Django React in Monolithic architecture to reduce over complexity and make things simple and clean. Since we don't have any CI/CD tools we are forced make some automation in our existing Monolithic architecture to make our job ease.

So I've I have shared mine .bashrc commands to make managing Django's monolithic architecture easier in linux server.

Open .bashrc of your current user

nano ~/.bashrc

Alias Commands

I recommend using all the commands which were helpful to me in development. I have shared the commands and normal explanation about the usage.

Collectstatic

To Collectstatic files of Django's files and React files if configured in Monolithic architecture

alias Collectstatic='python3 manage.py collectstatic'

Createsuperuser

In Dev environment it is essential to create new user again and again. By using this command we can reduce repetition.

alias Createsuperuser='python3 manage.py createsuperuser'

Migrate

Migration is always a part of new update in Models of Django. So better having an alias is better

alias Migrate=' python manage.py makemigrations && python manage.py migrate'

Activate

Activating the virtual Environment for Django.

alias Activate='cd ~/project_dir && source ~/project_dir/vEnv/bin/activate && cd ~/project_dir/app'

Shell

Sometimes to manual migration of Data or executing any tasks using python and Django we need Shell command to make the things easier

alias Shell='python3 manage.py shell_plus'

RestartFrontend

After putting the static build file of React.js in Django's one of the static directory running this command Restarts the frontend.

alias RestartFrontend='Activate && Collectstatic && sudo  systemctl  restart  nginx && sudo  systemctl  restart  gunicorn'

RestartBackend

RestartBackend gets the latest version Django from Git main branch and Make migrations and collecting static files making Nginx and Gunicorn restart again.

alias RestartBackend='git fetch && git rebase && Activate && Migrate &&  sudo  systemctl  restart  nginx && sudo  systemctl  restart  gunicorn'

And it also essential when scaling it advisable to move to multiple micro services architecture. Until then these commands will be helpful for rapid development in Django and React.js

0
Subscribe to my newsletter

Read articles from JOY SAM RAJ directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

JOY SAM RAJ
JOY SAM RAJ

Hi there, I'm Joy I'm a full stack developer, mobile application developer, Cyber security analyst, SEO analyst, trainer. Check my latest updates in www.joysam.me