Journey to Backend Development

Having been a frontend developer for years, transitioning to backend development was a bit of a struggle, but a fun one.

I started my journey in tech by learning Python, and it always stuck with me. That’s why there was no surprise when I decided to c…


This content originally appeared on DEV Community and was authored by Oluwanifemi Latunde

Having been a frontend developer for years, transitioning to backend development was a bit of a struggle, but a fun one.

I started my journey in tech by learning Python, and it always stuck with me. That's why there was no surprise when I decided to choose Django as the backend framework I wanted to learn.

Starting off, connecting to a database was a challenge for me. It was not easy to make a connection between my Django application and a database during a project I recently worked on. This problem hindered the development process and put the whole application in danger. In this task, I had to create a link connecting Django and PostgreSQL (it had to be done so that data could be fetched out of the storage as well as written in it).

Step-by-Step Solution

Step 1: Identifying the Problem
I examined the error logs and found that connection timeouts were frequent when the application attempted to connect to the database. It meant there was a potential problem with either the database server or the connection string.

Step 2: Setting Up PostgreSQL
I made sure that PostgreSQL was installed and running properly. I used the commands below on my local machine to verify the status and start PostgreSQL service:
sudo service postgresql status
sudo service postgresql start

Step 3: Configuring Django Settings
I then made changes to settings.py in my Django project to set up the correct configuration of the database. This is in the folder named after your project under the main directory of the project. There was also some settings in the form of the database name along with the user, the address of the database server (host) as well as the port number if any.

The following is part of the amended settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'mydatabase',
        'USER': 'oluwanifemi',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Step 4: Installing psycopg2
To enable Django to communicate with PostgreSQL, I needed to install the psycopg2 library, which is the PostgreSQL adapter for Python and it was done using pip.

Step 5: Applying Migrations
With the database configuration set up, I applied the migrations to create the necessary database tables.

Step 6: Testing the Connection
To verify that the connection was successful, I created a simple view in Django to interact with the database. I added a new entry to one of the models and retrieved it to ensure data was being stored and fetched correctly.

I enjoyed solving the back-end challenge because it helped me understand that being persistent in my learning process is paramount. That's why I believe that I should move forward with learning through the HNG internship. As such, I feel excited to solve harder puzzles as well as work with experienced developers and those who resemble me in their reasoning practices for lifelong learning. Through the HNG Internship program, my growth potential is limitless due to the opportunity it provides in terms of access to various mentors, enabling me to sharpen these skills in backend development.

I encourage anyone interested in enhancing their technical skills to explore the HNG internship program. You can learn more about the program here and you can also apply for the premium feature here.


This content originally appeared on DEV Community and was authored by Oluwanifemi Latunde


Print Share Comment Cite Upload Translate Updates
APA

Oluwanifemi Latunde | Sciencx (2024-07-02T13:35:03+00:00) Journey to Backend Development. Retrieved from https://www.scien.cx/2024/07/02/journey-to-backend-development/

MLA
" » Journey to Backend Development." Oluwanifemi Latunde | Sciencx - Tuesday July 2, 2024, https://www.scien.cx/2024/07/02/journey-to-backend-development/
HARVARD
Oluwanifemi Latunde | Sciencx Tuesday July 2, 2024 » Journey to Backend Development., viewed ,<https://www.scien.cx/2024/07/02/journey-to-backend-development/>
VANCOUVER
Oluwanifemi Latunde | Sciencx - » Journey to Backend Development. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/02/journey-to-backend-development/
CHICAGO
" » Journey to Backend Development." Oluwanifemi Latunde | Sciencx - Accessed . https://www.scien.cx/2024/07/02/journey-to-backend-development/
IEEE
" » Journey to Backend Development." Oluwanifemi Latunde | Sciencx [Online]. Available: https://www.scien.cx/2024/07/02/journey-to-backend-development/. [Accessed: ]
rf:citation
» Journey to Backend Development | Oluwanifemi Latunde | Sciencx | https://www.scien.cx/2024/07/02/journey-to-backend-development/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.