Contributing to Django Framework is easier than you think

Anderson Resende
February 15, 2017
<p>For those who are starting to code and wish to make open source, sometimes it is hard to start. The idea of contributing with that fancy and wonderful lib that you love can sound a little bit scary. Lucky for us many of those libs have room for whoever is willing to start. They also give us the support that we need. Pretty sweet, right?</p><p>Do you know that famous python framework? <a href="https://www.djangoproject.com/">Django</a>! There is one section on their website called <a href="https://code.djangoproject.com/query?status=!closed&amp;easy=1">Easy Pickings</a>. It was made for you who is willing both to get started with Open Source and to contribute with an amazing lib!</p><p>In this blog post I will show you step-by-step how I got started contributing the to open source by fixing a <strong>Django easy pick</strong> issue and how you can do the same in few steps. I will use a bug fixed by me to explain everything from the beginning to the end. Bear with me!</p><h2 id="finding-a-fix-bug">Finding a fix/bug</h2><p>The first thing that you need to do is to visit the Django section <a href="https://code.djangoproject.com/query?status=!closed&amp;easy=1">Easy pickings</a>. There you can find tickets that are easy to fix and small bugs. Every day new tickets are posted there. Try to find a ticket that is not assigned to anybody. Look at the image below:</p><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/d7/a3/d7a34921-1f76-49f3-89e0-e0d35c0d552c/easy_pickings_search.png" class="kg-image" alt="Alt text"></figure><p>In my case I choose that <a href="https://code.djangoproject.com/ticket/26026">bug ticket #26026</a> and assigned it to myself, let's take a deeper look into the issue. In the image below I am just showing the header of the ticket. Please read the complete ticket.</p><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/25/92/2592c87c-c1e0-4a32-b8d5-97e35df7dcd6/easy_bug_card.png" class="kg-image" alt="Alt text"></figure><p>As I have told you before, I have already solved this bug. So I am assigned to it, the bug is closed and there are some related PRs. When you choose a bug don't forget to assign the bug to yourself. This will prevent other people from picking the bug to work with. You need to be logged on the Django site, there are links on the top of the ticket page for that.</p><p>If you opened the ticket you will probably have noticed some discussions where the people suggested some solutions and made comments about the problem. People in the community are normally very helpful.</p><p>Ok! We've found and understood an open ticket.</p><h2 id="let-s-code">Let's code</h2><p>The first step is to fork the <a href="https://github.com/django/django">Django repo</a>. Second, write your code and make a commit following the style suggested by <a href="https://docs.djangoproject.com/en/1.10/internals/contributing/committing-code/#committing-guidelines">Django's guidelines</a>. Take a look at my commit name: <em>[1.9.x] Fixed #26026 -- Checked if the QuerySet is empty</em>. So you can finally make a pull request.</p><p>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.</p><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/03/35/03350a59-e487-4d51-bcee-01a86e5c9bed/unmerged_pr.png" class="kg-image" alt="Alt text"></figure><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/c3/c8/c3c817a7-bef7-4fda-96ea-12f01d016847/unmerged_pr_code.png" class="kg-image" alt="Alt text"></figure><p>Simple, don't you think? That was my solution, just one line of code. But check bellow the answer I got:</p><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/d0/78/d07800d2-d0a4-42db-a285-a011eb4744f9/unmerge_pr_comment.png" class="kg-image" alt="Alt text"></figure><p>Uhumm... 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!</p><p>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 (Is the same name of my PR).</p><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/0d/fc/0dfcc5a4-dd68-4c39-b7ea-151c44933799/merged_commit_pr.png" class="kg-image" alt="Alt text"></figure><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/3c/1b/3c1b3d9c-f8fc-4a3a-a393-2e6fa8af52d5/merged_pr_code.png" class="kg-image" alt="Alt text"></figure><p>Done! My PR was merged and closed. I have contributed to the amazing Django!</p><figure class="kg-card kg-image-card"><img src="https://vinta-cms.s3.amazonaws.com/media/filer_public/fb/08/fb08867f-2c67-4bed-a7ee-d66839d92cae/dead.gif" class="kg-image" alt="Alt text"></figure><p><strong>More from Vinta</strong><br><a href="https://www.vinta.com.br/blog/2016/controlling-access-a-django-permission-apps-comparison/"><strong>Controlling access: a Django permission apps comparison</strong></a> <br><a href="https://www.vinta.com.br/blog/2016/python-api-clients-with-tapioca/"><strong>Python API clients with Tapioca</strong></a></p>