Learn how to fix a Django bug from beginning to end


[ad_1]

For those who are starting to code and want to make open source software, sometimes starting is hard. The idea of contributing with that fancy and wonderful library that you love can sound a little bit scary. Lucky for us, many of those libraries have room for whoever is willing to start. They also give us the support that we need. Pretty sweet, right?

Do you know that famous Python framework, Django? There’s one section on their bug track website called Easy pickings. It was made for anyone willing both to get started in open source and to contribute with an amazing library.

In this article, I will show step by step how I got started contributing to open source by fixing a “Django easy pick” issue, and how you can do the same in few steps. I will use a bug I fixed to explain everything from the beginning to the end.

Finding a fix or bug

You need to be logged into the Django bug tracker site, then visit the Django section Easy pickings. There you can find small bugs and tickets that are easy to fix. Every day new tickets are posted. Try to find a ticket that is not assigned to anybody.

Django Easy Pickings

In my case, I choose the bug ticket #26026 and assigned it to myself, so let’s take a deeper look into the issue. In this image, I’m just showing the header of the ticket; the page contains more information:

Django Easy Bug Card

When you view this ticket, you’ll see I am assigned to it, the bug is closed, and there are related PRs. When you choose a bug, don’t forget to assign the bug to yourself. This will prevent other people from working on the bug.

People in the Django community are usually very helpful. On the page, you can see a few discussions in which people suggested solutions and made comments about the problem.

Let’s code

The first step is to fork the Django repo. Second, write your code and make a commit following the style you’ll find in Django’s guidelines. Take a look at my commit name: [1.9.x] Fixed #26026 — Checked if the QuerySet is empty. Now you can finally make a pull request.

Let’s take a look at my pull request and check the code I wrote. Note that I commented the PR with a link to the ticket it covers:

Django Unmerged PR Code

Simple, don’t you think? That was my solution—just one line of code. But here’s the answer I got:

The problem was that I made a pull request to the wrong version of Django. Also, I forgot to write tests to my fix. Let’s fix that.

This is my second PR, now against master and with tests alongside my code that I had already written. Notice that the name of my commit has changed (it is the same name of my PR):

Django Merged Commit PR

Django Unmerged PR Code

Done. My PR was merged and closed. I have contributed to the amazing Django project.

This article was reposted from the Vinta blog with permission.

[ad_2]

Source link

,

Leave a Reply