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 Django 1.8 and the template engines all got totally refactored, and Django Crispy forms stopped working because it would instantiate a template object without specifying the engine, the backend engine.
And this has been code 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 your back end.
And it's like, well, but there is only one, it was the default Django template backend, 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, and that 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 framework to Crispy Forms, Django 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 gotta do is find a is well, depend in this case I found a ticket.
Okay, I I I had a bug, I went on to I searched for it on Google, and up came on the Django issue tracker, the track, code.jjango project.com.
It came up with someone who'd 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 Django.
So type contributing to Django 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 the key
bit in it seems and it seems intimidating the first couple times you read it.
I speak from experience where I I had a couple years ago was was gonna try to do something and you know I had trouble getting it installed, and I was just like, Oh, I guess this isn't for me.
Right, yeah.
And it's
which is why we're doing this episode because we wanted talk through and how people not have that experience.
Right, and 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 onto 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 download the latest version of Django, or if you wanted 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, right.
You clone the master.
You always make a um 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 being you you are Django Fellows.
You are the Django Fellows.
I mean in principle there are other people that can merge pull requests, but in the reality is that the fellows do all the merge.
So don't let that be a barrier, just you just use matching.
So the first thing is clone the re the repo.
This is in the contributing guide, right?
So but clone clone the repository.
So click git clone, github, Django, Django.
Bam, and it will give you the version of Django.
Create a version environment, um, 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 um current directory run test.py, 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 in your Django project, you should at least be aware of of these tools.
Yeah, 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 if you have troubles getting Django up and running, you might have problem problems with your Python development.
Right.
Anyway, so it's probably these are things that you need to install.
And I wonder, it would I almost wonder if it would be worth having a Docker version.
Just so someone there is a Docker version.
There's a okay, yeah, it wants to do that.
I'm not afraid to be ignorant on the podcast.
Right, so brilliant.
So if this if it doesn't work for any reason, well there's there's a um a Docker box virtual machine, which you could download, and there's also a Docker um there's a Django box, which is a virtual machine, and there's a Django Docker box, which is a Docker um Dockerized instance.
So you can just Docker
on it and yeah, because I'm I'm all hopped up on uh 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 the stuff as much.
And I think in this case it's probably that situation where you just you download Docker, you you pull in the Docker Django version, and you can s 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.
I'm glad you broke the ice on saying something mean about Oracle on here.
Oh, well, you know,
it's early in the week, so why not?
Okay, so yeah, so anyway, you can 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, I 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 can 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 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 installed, build essential, or you know, whatever the the missing pieces.
Always be specific with your questions, it really helps everyone.
Yeah, if you don't give a like an actual error message or something, you've got no chance of getting serious help.
So, can you run the test suite?
Okay, fine.
You've got you've found a ticket.
Now that could be hard as well because there are there are like 1300 accepted open tickets on Django.
It's a mature project, it's got a lot of project uh, it's got a lot of open tickets.
So if you're just like, oh, I 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.
Um, 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
that'll that'll be easier way to get into it.
Yeah, focus on the problem that you've got to solve, uh, and that's the best way.
The second is well, filter it by um 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 a hundred on the admin, or you know, if you break it down by component, it's much more approachable than now.
Does 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 opened matter?
How how should someone evaluate that?
Okay, but if it 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 an admin, right?
So it's an ad so it's an admin thing.
Yeah, well, it's like, you know, it's probably not trivial because it would have been fixed.
Right.
Um, it's been looked at before, right?
Yeah, so if you're looking for low-hanging fruit, look for more recent ones.
More recent.
Well, there is an easy pickings flag which doesn't have a lot of tickets on it, and they're usually assigned.
If if there's a an easy pickings ticket that's been assigned, and 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 work on it.
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 jingle fellow will say, which is you need to have tests, comprehensive tests to back this up.
Okay, so the 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 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 you know the difficulty is they take time, and a lot of contributors uh English isn't their first language, and so it's difficult to for them to take on documentation tickets.
But if you've got strong written English, whether it's your first language or not, it in 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 you know, as a native English speaker, I would say sometimes sometimes people who said the first language is not English are far better writers because they have to be thoughtful about it.
Yeah, it you button what the bank is a little bit unfair.
It's not that you 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 that are existing docs are 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 and to close a lot of issues.
Um if there are issues that if there are pull requests which are open but need documentation to come in and help on those, you know, or need improvement, come in and help on those, take those issues over.
You know, most of the work might be done, maybe just needs a test.
Yeah, because yeah, because it you know it's a lot to to to to do a change.
You have to do the code, you have to write the test, and you have to document it, uh document it, and sometimes people get tired.
Yeah, and as well, that like the could there will be feedback.
So here's the thing.
So let's say you you've 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 you've you've some opened a pull request, right?
At that point you're gonna 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'll 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 reviews.
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 that we keep it high is by making sure that the changes that go in are 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 uh 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 the the top Django people here too, who are generally reviewing this.
So I mean you're just the educational component i is massive.
It's not Joe Schmo Joe Schmoe who's
Yeah, and to treat yeah, and to try and treat it as a learning opportunity.
And that that no one's trying to criticize anybody.
Right, I guess all they're trying to do is make sure that the patches are.
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, uh, is it it it's a gift.
Yeah, and uh 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 roll volunteers, and yeah, there sometimes there needs to be new blood or there needs to be something to push an issue forward.
And maybe it, you know, it 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 to does the documentation, to the extent that it there's just more people involved, it makes it better for everyone because you you know it's a it's a lot of work to do this.
And it's 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.
I you know, I haven't pushed to core Django.
I can imagine it's gonna feel great to have your work in actual Django.
Which super like you're this is your code now.
You own it, it's yours, it's it's your creation.
And 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 gonna interview for a Django job and you say, I've contributed to Core Django and I've learned all these things by doing core Django quality work.
I mean, even if it's just a single request, uh, you know, if I'm a hiring manager and someone tells me that, dang, that puts you top 1% for sure.
Because no, no, most people haven't contributed.
So one of the big things I talk about, and I it really I've you know I've done a lot of open source over the years, and starting with REST framework and it 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 requ hiring requests or for like code samples and things like this, they just disappeared because oh, I helped maintain Django Rest framework.
Oh, yeah, we use that, okay.
And it it 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 Rust 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, there they there's still in an interview you might mess up.
I'd um somebody asked me, uh, oh, you know, custom user model, and I'm like, ah, I totally like uh 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 in it, I was like in an unpressure situation and totally said the wrong things and didn't get the gig and oh well it doesn't matter.
No, it ha it happens to everyone.
Well, yeah, I I I I got I got rejected for a job writing uh code for Django 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 this is a great great way to maybe speed up those interviews a little bit.
So the look the take the take-home here, we're slightly digressing in terms the hiring disasters from helping, but the the 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 that's not tied into something that you're trying to create.
You get feedback from other people, you get to learn to un 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 Django, 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 Django's side, you can't expect it to be run on volunteer effort, it's just too much.
So we the triage thing is hard, it's really hard.
You spend, you know, you get a ticket and it you you look into it and you try and write a nice comment, and people are like cross with you because you you you didn't agree with their analysis, and it's like, no, I'm just trying to do the right thing, yeah.
I'm just trying to understand it, and then there's another ticket, and then 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, and the you know, there'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 to 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 gonna mention for for teams and companies, it 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 for your reputation for hiring people.
Uh, you know, it's uh you know, there are these selfless re 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 get like it 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 or on an open source source code base where you get free code review from community experts.
Yes.
Like it it's it's just a map to to allocate, you know, the 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 gonna 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 or worked on a ticket, just the process.
Again, think of it as free learning if you can.
No, but it 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 of when you're learning Django.
I mean, uh at least for me, I I would say I'm a 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 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.
Um, but it's taken a long time for me to get there.
And working on core Django tickets is just gonna ramp that up.
And once you it just is things opening left and right, once you sort of see how things fit together, it it becomes a beautiful thing.
You're like, oh man, I really start to finally it's like seeing the matrix.
You're 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 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 gonna start from scratch, how would we change things?
Like those are amazing conversations to have.
We'll 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 because 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, and it
but Okay, well don't start there.
Exactly, but slowly but surely, okay, you just dig into a a single lookup.
Okay I say oh I see how this lookup works okay I see how this expression works and okay the bits of the ORM just slowly start to come together and yeah it's
yeah I mean views views are a great one right like if you're curious how does a generic class based view work like list view 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 you know it'll show you where it all comes
to what to open up um um say Django.core.handlers which are the base whiskey handlers that handle the requests and to look at how the get response function works i it takes in a request and this is the this is the core of it and it builds the the middleware and it passes it through the middleware onion into the view and then back out from 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 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 in it and not you know and this is why we set the query set here and this is why you know those kind of things.
It does leave to an appreciation I think in general of the choices that are made and but you you understand the choices too even if you don't fully agree with them again when you get to this level.
Yeah and there's never going to be the perfect web framework right you can you can be like oh Django's done it all wrong and I'm gonna rewrite the red framework from scratch but in the end you're gonna end up making compromises which will mean
right and that's and that that is the thing is that it's it is all trade-offs and uh 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 uh talk like that to beginners when beginners say I just want to build a site and I you know don'
t d don't do that to them.
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 into 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 DjangoCon 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 like there's contributing to Django but then there's making sure that you don't get burnt out by contributing too much and there's you know how how do you how even if you've only got limited amount of time how do you make sure that you can still put to present your effort in a way that makes it 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 blog 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 depth Django community as a whole is 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 bit 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 I maintain on my own time Django filter um channels crispy forms I get 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 Core Django.
So so I found myself writing applications for you know big company big brands but it was all under NDA and so when I 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 it's a non-specific reference from it's not like hit I did this.
Right.
Well you're making me rethink uh you know I think we'll we'll do an episode on uh 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 there the 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 um
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 can sit home and build you know some demo app well okay that's that that's impressive too but it doesn't show teamworking skills it doesn't show communication skills it doesn't show all these other things which I re managers are coming to realize are
just as important if not more important.
Right and often the c open source code is almost always going to be better than non-open source code.
Well y yeah it's this um cathedral versus the bizarre 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 uh illuminated a little bit of the process of contributing to Django uh 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 comes chat Django on Twitter and uh see you next time Carlton
Alright bye bye take care