Simple To-DoWebApp Development Using Python-Django-React-Docker Tech Stack
Create TO-DO App Using Python-Django-React JS Stack - mandgenikhil/to-do-app
This is my first blog on medium, so please forgive me if I had any mistakes with my typo and the other aspects.
The reason behind writing this blog is to share the steps of how to build a full stack web-app using Python-Django web framework with React JS for front-end development and in the end, using Docker we can containerize the whole application into single deployment.
I know most of you will face some issues in order to understand few technical lingo’s. but ill try to make this very easy to know.
- Node-NPM and React JS
- Create REST API’s Using Python-Django web framework
Then for our web-app authentication, we have used Django, rest_framework.authtoken along with rest_auth. for more details you can refer to this GitHub repository.
After completing this setup, we need to create a model ToDo (table) for storing and having CRUD operations from front-end.
Then, for developing CRUD operations, we have used the following list of API’s
- api/v1/to_do (GET API)
- api/v1/edit_to_do (POST API)
- api/v1/delete_to_do (POST API)
- api/v1/save_to_do (POST API)
As URL’s are self explanatory, each API’s are performing the required task of listing to-do’s,saving, editing and deleting.
Note:- I have integrated the rest_framework with rest_auth, so that we have our two API’s for user registration and user login.
Once the operational code changes you have added in views.py file of respective url’s view. we are good to go with our REST API’s. As I have mentioned earlier, for your reference you can go through the code details in my GitHub repository.
2. Create Front-End Using React JS
For accessing the web-app we have defined our login page, as follows.
I have defined this login page details in my GitHub repository, please have a look. For this web page development I have used Bulma CSS and node sass.
For making an user login validation, I have used the “rest-auth/login/” REST API call, with valid inputs such as “username” and “password” from this web page.
After successful login, you will able to view the following page,
You can add your To-Do in the text box mentioned below and click on “save” to store the information in database. once you saved your To-Do, you will be able to view something like this,
You can delete the respective To-Do by clicking small “x” icon to the right most place. Also you can edit the To-Do with clicking the edit icon to the right.Once you click on edit icon of To-Do you will be able to view the following modal.
Once you type the required text in the edit text box, after clicking save button, your changes will be reflected directly.
All these save,delete,edit,view operations are performed using REST API’s defined earlier in our Python-Django To-Do App.
The React-Js build is under “template” folder of the project, We have used the React-JS build(using “npm run build” command for creating prod ready build) as Python template for rendering it into a single Django web-app.
3. Dockerize Entire Web-App
After completing the development, our web-app is ready to be Dockerize and hosted in any environment.For that you need to create DockerFile as follows,
Along with that, we have used Docker-Compose in order to host the docker image in our local machine.
Once you are ready with these file changes you can run your application successfully.
I hope this will guide you for developing and setting up your web-app along with containerize using Docker.