← Back to Show Notes

Transcript: Contributing to Django

Hello, welcome to another episode of Django chat. This week, we're going to be talking

about how to contribute to Django. I'm Will Vincent, and I'm joined as always by Carlton

Gibson. Hey, Carlton.

Hello.

So let's, let's talk about this, because this is something near and dear to your heart,

since you review all the commits to Django. And for me, when I'm out and about, I've actually

gotten this question a lot of experienced developers who've made changes in their own

projects and they say how do i contribute to django it seems like this black box so let's

unmask it for people so what's the first what's the first step let's say i've been using django

at work i've done some gnarly small specific bug fix and i'd like to share it with other people

what do i do let me talk about my first patch to django because that's the best right so um django

1.8 and the template engines all got totally refactored and django crispy forms stopped

working um because it would instantiate a template object without specifying the the engine the back

end engine and this has been cold that's been working forever since like 1.4 or something like

that and what django wanted you to do in 1.8 was to specify with your your back end and it's like

well but there is only one it was the default django template back end and can't we just use

that and well yes we could but it needed somebody to come along and fix it so i submitted a patch

got a couple of reviews it was easier to make a fix in Django than it was to make a fix in

Django crispy forms at this point so anyway then that got merged in and that was released in you

know the one of the subsequent patch releases so what do you do that was my first contribute to

Django core itself um I've been yeah I mean contributing to rest frameworks crispy forms

and filter and compressor all over the place but I hadn't actually contributed to Django

curious isn't it anyway what do you do you the first thing you've got to do is find a is well

depending in this case i found a ticket okay i i had a bug i went on to search for it on google

and up came on the django issue tracker the track code.djangoproject.com it came up with

someone had reported this issue and i'm like oh i've got this issue i need to fix this

so okay what do i do well then you go and read the very fine manual and it's there's a how to

contribute to jango so type contributing to jango in the top hit will be from the docs how to

contribute and have a read through that um and it says you've got to do various bits and bobs the

key bit it seems it seems intimidating the first couple times you read it i speak from experience

where i i a couple years ago was going to try to do something and you know i had trouble getting

installed and i was just like i guess this isn't for me right yeah and which is why we're doing

this episode because we want to talk through and have people not have that experience right what

we want and this is something that as a community we've got to work on harder is to lower the entry

ramp yeah so people want to contribute and there's a lot of millions of django users we want to make

it smoother for them because there's obviously a barrier to entry because we're not getting as

many contributors as we want and maybe i wonder if i wonder if having because i think that you

know so if you go on to github you can see the source code for django and then within that is

where you can go find the what's the technical term the version that you would the latest version

of django or if you want to go in and make a contribution right that there's the separate

oh right so yeah so you get you clone the repo so you always you always right yeah you clone them

yeah you clone the master you always make a pull request a change request against master the latest

master and then if it needs to be backported to a supported version then we will do that when we

merge it so we're being you you a django fellows i mean in principle there are other people that

can merge pull requests but the reality is that the fellows do all the most so don't let that be

a barrier just just use master so the first thing is clone the repo this is in the contributing

guide right so but clone the repository so click git clone github django django and it will give

you version django create a version environment and change into the test directory and pip install

the requirements for python 3 and then run tests there's a file in the test folder called run test

so current directory run test dot pi and it should run the test suite and i say should you need to

have the right libraries installed on your computer and all those things so there may be there may be

glitches but this is also a good educational thing because if this works for the django core team

and you're not using it your django project you should at least be aware of these tools yeah i

I mean, so, like, for instance, you might not have the right development headers for the database installed, so it can't compile the dependency.

You know, there are various things.

But if you have troubles getting Django up and running, you might have problems with your Python development.

Right.

Anyway, so it's probably these are things that you need to install.

And I wonder, I almost wonder if it would be worth having a Docker version.

There is.

There is a Docker version.

Oh, okay.

I'm not afraid to be ignorant on the podcast.

Right.

So, brilliant.

if this if it doesn't work for any reason well there's there's a um a docker box virtual machine

which you can download and there's also a docker um sorry there's a django box which is a virtual

machine and there's a django docker box which is a docker um dockerized instance okay great

yeah because i'm i'm all hopped up on a docker because i'm using it in my new book in part to

solve these local development challenges and you know i would say the docker it is a million

lines of of code so it can it can get hairy but it also often can just work for you and be amazing

and you don't have to worry about this stuff as much and i think in this case it's probably that

situation where you just you download docker you pull in the docker django version and you can

just get going because it will just have everything uh self-encapsulated for you

yes and it's very good as well because it um handles so we support sqlite mysql postgres and

oracle well who's who's got set up with oracle no one but the docker box will do that for you

so i'm glad you broke i'm glad you broke the ice on saying something mean about oracle on

oh well you know it's early in the week so why not okay so yeah so anyway you get the test

to get the test the first thing to do is get it installed and get the test suite running and

whether you do that locally by creating a virtual environment installing the dependencies or whether

you use docker or the virtual machine doesn't really matter but can you run the tests yes okay

can run the test if you can't then Django users or Django developers or there's

another maintenance called Django core mentorship which you could go on and say

and be specific say I'm trying to get set up to run the test suite the

problem I've had is exactly this can anybody advise and there are a lot

Lots of people who, if you give a nice specific question like that, will be able to say, oh, you know, you need to apt-get, install, build essential or, you know, whatever the missing pieces.

Always be specific with your questions.

It really helps everyone.

Yeah.

If you don't give like an actual error message or something, you've got no chance of getting serious help.

So can you run the test?

Okay, fine.

You've found a ticket.

Now, that could be hard as well because there are like 1,300 accepted open tickets on Django.

It's a mature project.

It's got a lot of open tickets.

So if you're just like, oh, I'm looking for a project and you start browsing,

you could be there a long time before you find something that you think is suitable.

So two things I'd say there.

One is, have you got an actual issue that you want to solve?

If you have, that would be the first place to do it.

That'll be an easier way to get into it.

Yeah, focus on the problem that you've got to solve, and that's the best way.

The second is, well, filter it by component.

Because if you, you know, there might be 1300 tickets, but there's only a couple on the syndication framework, or there's only 10 on the email, or there's only 100 on the admin, or, you know, if you break it down by component, it's much more approachable than...

Now, what would you say in terms of, you know, what about, you know, looking at the most recent ones or looking at the oldest ones, does the time that a ticket's been open matter? How should someone evaluate that?

Okay, so if there's a ticket that's been open for 13 years...

And it's still open, it's probably got...

It's probably got some comments on it.

It's probably hard as now.

So it's an admin thing.

Yeah, well, it's like, you know, it's probably not trivial because it would have been fixed.

It's been looked at before, right?

Yeah, so if you're looking for low-hanging fruit, look for more recent ones.

More recent ones.

There is an easy pickings flag, which doesn't have a lot of tickets on it, and they're usually assigned.

if there's an easy pickings ticket that's been assigned and it but it's it was assigned six

months ago or a year ago well just comment say are you still working on this can i take it

can i take it over because sometimes people assign themselves a ticket and then they'll walk

and that's a great one to look at to learn too because a common issue is someone will solve a

problem but not have complete tests to back it up which is probably like the number one feedback

someone like you as a jingo fellow will say which is you need to have tests comprehensive tests to

back this up okay so here's a good one so look on um tickets which have got patch needs improvement

or needs documentation document yeah actually documentation is probably the number one way to

start right well if you've got if you've you know if you if you've got strong written english then

there are a lot of documentation tickets which the difficulty is they take time and a lot of

contributors that english isn't their first language and so it's difficult for them to take

on documentation tickets but if you've got strong written english whether it's your first language

or not and you can write clearly it's a really good way to get to understand more about the

framework because you have to get into the issue you have to understand the issue and then you have

to write about it clearly yeah no i i agree and i was as a native english speaker i would say

sometimes people who's at the first language is not english are far better writers because they

have to be thoughtful about it yeah but it is a little bit unfair it's not that you're not that

english is your first language or that your native language but you do need to have quite strong

english and you need to be able to write yeah the docs are well the existing docs are very well

written so but there is a massive opportunity for people with strong written english to contribute

to django and make a big difference to close a lot of issues um if there are issues that if there

are pull requests which are open that need documentation to come in and help on those

you know or need improvement come in and help on those take those issues over

well, most of the work might have been done.

Maybe it just needs a test.

Yeah, because it's a lot to do a change.

You have to do the code, you have to write the test,

and you have to document it,

and sometimes people get tired.

Yeah, and as well, there will be feedback.

So here's the thing.

So let's say you've installed Django,

you've got the virtual environment set up,

you've run the test suites, you've found a ticket,

you've made a patch, you've opened a pull request.

at that point you're going to get reviews and there's a patch review checklist and there's

coding styles but that review will be quite um precise it will be very it will be like please

make this small change please make that small change and then you'll make those changes then

then there'll be more review and it's not it's not like a criticism of you personally it doesn't

matter who you are you get exactly the same review and the same comments made it's that the quality

of django is very high and the way we keep it high is by making sure that the changes that go in are

just right and it's it's a gift to have precise feedback from a knowledgeable person too i think

you know if you're not used to a lot of people maybe aren't used to feedback like that and if you

aren't used to it it can feel a little jarring but it is truly a gift for someone to be that precise

with you you know you're dealing with the the top django people here too who are generally

reviewing this so i mean you're just the educational component is massive it's not joe

Joe Schmoe who's yeah and to treat yeah and to try and treat it as a learning opportunity and

that no one's trying to criticize anybody right I guess all they're trying to do is make sure that

the patches right I guess that's my point if someone didn't care they wouldn't engage with

you the fact that someone engages with you especially when we're all working towards the

same goal is it's a gift yeah and what do I think so there's two bits that I think that we struggle

with contributors one is the on-ramp that we briefly mentioned is that people start and it's

very hard to get going the other is i think people do get disheartened by the review process and how

it can feel slow and patches can get stuck and what yeah how do you break how do you break through

that right because there that is a common thing if you basically we're all volunteers and yeah

there sometimes there needs to be new blood or there needs to be something to push an issue

forward and maybe you know it also can be as simple as if you're the one who's done the initial code

and then you just get swamped and you can't do the documentation if someone else comes in

does the documentation to the extent that there's just more people involved it makes it better for

everyone because you you know it's it's a lot of work to do this and it feels great to have someone

new or someone from outside come in and focus on what you're focusing on and help out and do all

these last little things you know i haven't pushed to core django i can imagine it's gonna feel great

to have your work in actual django it's super like this is right now you own it it's yours it's

it's your creation and you can you know uh if you want to be selfish about it it's a pretty

nice thing to talk about in interviews if you're going to interview for a django job and you say

i've contributed to core django and i've learned all these

these things by doing core Django quality work I mean even if it's just a single request you know

if I'm a hiring manager and someone tells me that dang that puts you top one percent for sure really

because not most people haven't contributed so one of the big things I talk about and it really

I've you know I've done a lot of open source over the years and starting with rest framework and

growing into other packages in the Django ecosystem and then ended up you know I'm the Django fellow

now it's amazing but from the second i started contributing to open source all of a sudden

hiring requests or for like code samples and things like this they just disappeared

because i've come i helped maintain general reframing oh yeah we use that okay

and it totally changed the dynamic for me as it should but yeah well we were just we were just

discussing you know right before recording you know in my case i'm an educator i don't get quite

that benefit of the doubt even though i've done all these books um which is fair enough but if

you have actually contributed and gone through the steps to go through core django or django

rest framework there's no higher bar than that in terms of do you actually know what you're doing

and do you can you write quality code yeah i mean although you know they're still in an interview

you might mess up like um somebody asked me oh you know custom user model and i'm like i totally

like and what i should have done was just cracked open the docs and gone and looked it up because

that's what i do in real life but i was like in an unpressured situation and totally said the wrong

things i didn't get the gig and oh well it doesn't matter no it happens to everyone well yeah i i i

got i got rejected for a job writing uh code for jenga rest framework at the same time i was

finishing my book on it the best-selling author of the yeah best-selling author because the only

author at the time but um yeah so this is a great way to it's a great way to maybe speed up those

interviews a little bit so look the take the take home here we're slightly digressing and

hiring disasters from the take home is that if you contribute to open source it does actually

help your job it's a massive learning opportunity because you get to see good code and it's not

tied into something you're trying to create you get feedback from other people you get to learn

to understand a code base which is foreign to you the danger is that you get sucked in and spend too

much time of it and you've got to be careful you've got to limit the time that you give to

open source is that the the meat grinder you've referred to well it's not i hadn't heard this

phrase actually but like the the um the old school contributors to jango they used to describe it as

the meat grinder because it eats contributors right and so well we need some fresh meat for

the meat grinder because you triaging tickets is hard and this is this was the why the fellowship

program exists is because ultimately a project of jango's side you can't expect it to be run on

volunteer um effort it's just too much so the triage thing is hard it's really hard you spend

you know you get a ticket and you look into it and you try and write a nice comment and people

are like cross with you because you you didn't agree with their analysis it's like no i'm just

trying to do the right thing i'm just trying to understand it and then there's another ticket and

there's another ticket and it's endless it's truly endless and you know you take the weekend off and

you come back monday in the roof you know it's 15 you take oh it's like oh my word and you can't do

that on a volunteer basis so the so the fellowship program is we handle the triage we handle the code

reviews we handle the releases and then hopefully volunteers that's you people you couldn't can come

and do the fun stuff like writing some code to fix django yeah and i was going to mention for

for teams and companies it's also if you can say and you know people on company time or the company

is a contributor to core django that is also a massive help um for your reputation for hiring

people uh you know you know there are these selfish reasons uh reasons for contributing to

django in addition to it helps improve the thing that you are using to run your business day to day

yeah and it helps you get like it makes your employees better coders yeah right and they

will experiment they will do learning they will do all these things and it's either going to be

on your code base yes or on an open source source code base where you get free code review from

community experts yes like it's it's just a map to allocate you know the google 20 time you don't

have to allocate 20 but something like approaching that to work on the dependencies of your own

project that's a time well spent yeah and i think i'm i'm glad we're going to list the resources

here where if you do get stuck trying to contribute and you have a specific question you can go and

ask for help and be helped because again there's those two stages of just just getting everything

up and running which sometimes puts people off and then there's once you've contributed um i worked

on a ticket just the process again think of it as free learning if you can no really it kind of is

i mean you know and it is and it is i mean i look at you know that i think this is the progression

too when you're learning django i mean at least for me i would say i'm a bit behind you carlton

on the django expert level but you know these days i just go look at the source code on stuff

yeah you know i used to be i would go online i'd look at tutorials i'd look at the docs you know

at this point, I basically quickly look at the docs, and then I usually jump into the source

code on most things. But it's taken a long time for me to get there. And working on core Django

tickets, it's just going to ramp that up. And once you it just is things opening left and right,

once you sort of see how things fit together, it becomes a beautiful thing. You're like, Oh, man,

I really start to finally it's like seeing the matrix like, Oh, this is how this ties in with

this, you know, because you just accept everything when you're starting out. And,

you know, we just sort of muddle through, but there's a real beauty in seeing how a web

framework works. And then you can see, oh, these are the choices Django made and, you know, have

these, you know, philosophical conversations about, well, if we were going to start from

scratch, how would we change things? Like those are amazing conversations to have. We'll probably

have these in the podcast, but you, you get that by doing the work and digging in and understanding

the source code. Cause it's, it's also, it's all in Python. It's, it's, it's very readable. It's

not, you know, mysterious if you take the time to look at it. Yeah. I mean, like, you know,

you get right into the ORM,

there's a lot to take in.

Okay, well, don't start there.

Exactly, but slowly but surely,

okay, you just dig into a single lookup.

Okay, oh, I see how this lookup works.

Okay, I see how this expression works.

Okay, the bits of the ORM

just slowly start to come together.

Yeah, I mean, views are a great one, right?

Like if you're curious,

how does a generic class-based view work,

like list view?

Look at the source.

You can read the documentation,

you can look at classy class-based views.

And then if you look at the source,

it will reference, it'll show you where it all comes from.

Yeah, and to open up, say, Django.core.handlers,

which are the base Whiskey handlers that handle the requests,

and to look at how the getResponse function works,

i.e. it takes in a request, and this is the core

core of it and it builds the middleware and it passes it through the middleware onion into the

view and then back out it's like oh that's how it works and then all of a sudden middleware

aren't as mysterious as perhaps you thought they were yeah or even just the idea of um you know

the context object that's passed into templates that's something that when you're learning it's

just like oh there's something called objects oh i can rename it but like what is it you know you

don't you don't necessarily get it because you're just so overwhelmed with everything else but um

Yeah, I guess we're saying there is a real beauty in seeing how the pieces fit together.

It gives you the opportunity then to, when you're writing Django, when you're writing

your application, once you sort of know how the form layer really works, you're like,

oh, and this is why we create the form this way.

And this is why we update the fields in it and not, you know, and this is why we set

the query set here.

And this is why, you know, those kinds of things.

It does lead to an appreciation, I think, in general of the choices that are made.

And you understand the choices too, even if you don't fully agree with them, again, when

you get to this level yeah there's never going to be the perfect web framework right yeah you can

you can be like jango's done it all wrong and i'm going to rewrite the red framework from scratch

but in the end you're going to end up making compromises which will mean right and that's

and that is the thing is that it is all trade-offs and but i think you have to have a certain level

to discuss the trade-offs in an interesting way versus you know i i see engineers often

talk like that to beginners when beginners say i just want to build a site and i you know don't

don't do that to them to help them build something and then you can talk about it um

because again this is this is a big point of this podcast is that there's a lot of things in django

that are maybe maybe this maybe that and we want to talk about it as professional developers would

and give that context because there aren't that many things that there's one right answer though

there can be good answers and bad answers so that's what we try to talk about yeah and yeah

so but what would we say here we say yeah digging into the source gives you that insight digging

the source is worth it contributing to django is absolutely worth it and there are resources to

help you get started and what else you're you're doing your talk at um django con europe which

probably won't be up for a little bit is on this topic yeah exactly on how to contribute and how

to how to make that work for you so there's there's contributing to Django but then there's

making sure that you don't get burned out by contributing too much and there's you know how

how do you how even if you've only got a limited amount of time how do you make sure that you can

still put to present your effort in a way that makes it um the transparent to prospective employers

the value of what you've done because you think oh I've only can you know I've only spent half an

hour and a week for six weeks and that's actually quite a lot and if you just keep a log of that and

if you just present it in the right way that shows a lot to an employer that gives you an advantage

because one of the one of the big issues that we have is that not just that we don't have enough

contributors but the contributors are all from that same stereotypical demographic of white male

you know it's not entirely white it's not entirely male but it's largely white and largely male

and the Django community as a whole is much more diverse than that and the danger with open source

is that it just reinforces the the same privileges it's it's only the people who can afford to give

the time to it that do give the time to it well yes if you're going to give hours and hours and

hours to open source you need to be quite privileged to be able to do that but you can

give a small amount of time and if you track that that can help you build a career around it or can

can help push forward your career which gives you more time so when i started when i started

contributing to open source i'm a father of four young kids i was consulting you know doing

freelance and agency work with django and in ios but i was contributing in my spare time but i

didn't have lots and lots and lots of spare time i and i still don't have lots and lots of spare

times you know i i maintain on my own time django filter um channels crispy forms i give these what

i can but it's not a lot but it adds up over time you know do it month in month out and all of a

sudden it's like oh wow actually you've done a lot and the kid the key the key for me is not to

not to think you have to somehow find 10 hours a week you don't have to find 10 hours a week

you know if you can find some time on a regular basis however small that is that adds up to

something really substantial i agree and it's all it's all out there you can point to it the work

is visible in the community.

Yeah.

So there's no questions of ownership.

You know, sometimes if you're at a company,

you can't show the work that you've done,

but you can show work you've done on CoreDjango.

So I found myself writing applications for,

you know, big companies, big brands,

but it was all under NDA.

Yeah.

And so when I'd go for other work,

it was really hard to present, you know,

I could, okay, you should get a reference,

but well, it's a non-specific reference.

It's not like, hey, I did this.

Well, you're making me rethink, you know,

I think we'll, we'll do an episode on hiring in Django and what to, what can you do? I've always

told people, you know, build, build a bunch of projects and open source your work, but you know,

that's a lot of work and maybe that's more than you're able to do. You know, if you can just go

in and do documentation on core Django in some ways, that's probably better actually than just

building a blog or whatever project. Hard to say. It definitely, it definitely, it definitely helps.

And I think it's an avenue that, yeah, we want to highlight. What are hiring managers looking for?

They're looking for good teamwork, good communication skills, you know, all these things, which if you can work on an open source project with other people, it demonstrates all of those.

Whereas if you could sit home and build, you know, some demo app, okay, that's impressive too, but it doesn't show team working skills.

It doesn't show communication skills.

It doesn't show all these other things which hiring managers are coming to realize are just as important, if not more important.

Right.

And often the open source code is almost always going to be better than non-open source code.

No, yeah, it's this cathedral versus the bazaar thing.

Yeah, so, great.

All right, well, I think we've covered the main points,

and hopefully we've, again, look in the show notes,

we've illuminated a little bit of the process

of contributing to Django,

demystified a little bit,

and tried to make points for why it's well worth your time.

It's not just a yeoman's work.

Yeah, it's a really good thing to get into,

and you'll learn a lot.

Yeah, great.

All right, well, I will see you next week.

As always, you can view this episode and others

on DjangoChat.com,

ChatDjango on Twitter,

and see you next time, Carlton.

All right, bye-bye.

Take care.