Django Journey…

Okello Marvin Kevin Ochira
3 min readNov 10, 2022

--

So I have been working on two systems working on the frontend using Angular. The project are almost complete and I have been thrown in the deep end as I will be the one maintaining the systems and adding new features, and fixing the existing bugs, this implies also doing development for the backend which is Django.

I have always wanted to learn Django well and become an expert in this field of Django and Python, things always came up, new languages to learn, projects to accomplish. But having completed the university, I find my self with time and something concrete to push me to master Django very well.

Step 1: Watch a Video giving me the big picture.

Ive made myself familliar with Django, the structures, which architecture it uses, which type of files handle which functionalitites etc I started with a video of Mosh Hamedani ;

I like watching his videos cause he ellaborates and explains very well why things are the way they are. At the end of this video, together with past materials, I have read, I have a better understanding of how Django works.

So as an Angular developer in the past projects I have been working on, I have always asked my colleauge who works on the backend for endpoints where I will submit data or where I will retrieve data from. I always got these URLs where I would make GET, POST, DELETE, UPDATE, PATCH requests. All I had to do was know the model the backend was expecting and then I’d post data in the required format. So I been curious to know how he handles all the data.

Step 2: Do the actual work (Implement a Restful API)

My first task is to create a simple Restful API eg heroes where I can create heroes, delete and update, basically perform CRUD actions. This will be without relationships with other models just so that I can get the basics right. At the end of it, I have to deploy it, but that will be in another blog all together.

So the task is to create a Restful API, but that sounds like a huge task, so I break them down into small managable steps;

  • create a Django project
  • create an app called api
  • Register the app under installed apps in settings
  • In the app create a model for heroes
  • create the neccessary routing
  • create a serializer
  • Register the model in admin.py witin the app
  • Connect the database to store the data
  • run the Django application
  • create a super user
  • Log into the admin panel on the web interface
  • Add some dummy data from the web interface
  • Go to Postman and add data as if coming from the client

Someone who doesnt know, will ask, “How did you know that you will do all these steps?

I watched Mosh’s video and a couple of others and wrote down the steps required to make a restful api. This is the result of knowing how the framework works.

At the time of writing this blog, I have completed these tasks and have successfully made a restful api. I added data via postman to be sure that the endpoint it receiving data from a client.

So after these steps, I am not yet an expert but I can now do something, so now I have to use these building blocks to broaden my knowledge and face more complicated tasks such as models with relationships. I am also interested in knowing how to implement the login backend. So I will deploy this application and then proceed to implement more complicated models..

Resource used: Build a REST API in 30 minutes with Django REST Framework

Thanks for reading, see you at the next blog…

--

--

No responses yet