Day 3 Lightning Talks

This video is from DjangoCon Europe 2019 in Copenhagen, Denmark.

Day 3 Lightning Talks
0:49:35
Published April 23, 2019
646 views

Summary

The lightning talks cover a range of practical Django and Python topics. Speakers recommend keeping configuration coherent with class-based settings or typed environment-backed configuration, passing only serialized primitives to templates to make database work explicit and prepare for APIs, and using state machines to prevent race conditions during concurrent model updates. Other talks explain how Apollo 11’s priority-based real-time scheduler handled CPU overload, compare Elasticsearch integration options, and show how the offline-first, open-source Kolibri platform uses Django to deliver education in places without reliable internet. The session also highlights Python communities and conferences across Africa and invites attendees to contribute at the Django sprints.

Key takeaways

  • Typed configuration and safe environment-variable defaults can make deployment settings easier to manage without inconsistent files.
  • Serializing template context into Python primitives forces explicit I/O, reduces bloated model logic, and eases caching or later API conversion.
  • Database-backed state transitions should lock and reread current data so concurrent workers do not create race conditions.
  • Apollo’s guidance computer used priority scheduling to preserve mission-critical work when the system exceeded its CPU capacity.
  • Kolibri uses Django and open-source educational content to provide learning resources offline on low-cost or legacy hardware.
  • Django sprints are open to beginners and include documentation, bug fixes, ticket triage, and community projects.

Summarised automatically from the transcript.

Transcript

6,840 words · auto-generated Show

Automatically transcribed, so expect mistakes in names and technical terms.

0:00

Speaker 1: So I am from Namibia and I've been a high school teacher for the past three years. I've taught computer studies to learners of ages between 13 and 19. And right now I'm a full time student. Uh and we are not there yet. Are we there? Okay, so Okay, so last year I was at Django Con Europe twenty eighteen. And I gave a talk at the conference, and one of my friends was also an organizer at that conference. So when I went back home

0:46

Speaker 1: I also wanted to be an organizer. Back home, I organized PyCon Namibia and I organized lots of Python workshops and events back home. I work a lot with high school learners as well. We organize a workshop, not a workshop, but a conference for high school learners. So I was interested to learn how the international world organized conferences, and I also wanted to be an organizer. So I wrote to the organizing team when I knew where the conference uh was going to be. And I would like to thank uh the organizing committee for welcoming me and for making the whole journey of organizing a conference such a pleasant one. And also while we were organizing, we most of us had

1:32

Speaker 1: not done such a big, big, big conference before. So we had a lot of mentorship and help from the guys who organized uh DjangoCon Europe 2018 from Heidelberg. So we would like to thank you guys for your guidance and for your support throughout the organizing of the conference. So let's give them a hand of applause We are there now.

2:09

Speaker 2: Hear me? Ah, there I am. Oh, that light's nasty. So somebody did a talk yesterday about uh configs and settings and how to deal with them and environment variables and so on. And I didn't 100% agree with it, so I wanted to present a different view on handling settings Many people like using multiple files. I don't think so, no. Main reason is because of the concept of update anomaly. Maybe you have your static files in one file and then you change it in another one. But then they don't match and they should match. And okay, yeah, there are ways of dealing with this, but sometimes that's a

2:54

Speaker 2: A um a discipline we're not always so good with. So there are several tools that I've built along the time, thank you, Russell, for uh dealing with this sort of problem. Um also environment variables. Definitely agree with environment variables. Because they're driven by the running environment. It's not something that's controlled by your application. It's something controlled by the environment in which your application runs. That's the whole concept of environment. variables. But remember that you need safe fallback defaults. If the environment variable doesn't set something, you need to need something so that for instance if you're running in development or staging you don't go and touch your production database that can be bad So here's some tools.

3:40

Speaker 2: The first one is one called Django Classy Settings. Can I have some hands up about who has ever heard of or used this tool before? Cool. Hey, even some wow. Okay, good. So basically, uh you and you import it, the um class-based settings was the original name. You define a class, uh anything that's Shouty snake case sort of uh names will be exported from it when you get there. And you can of course because it's a class you can inherit and extend and so on. You might have your staging settings, your production settings, and of course in your production settings you want to set the bug to be false. You don't want to have to remember that. And then you can just use this to go and say, hey, I'm going to switch which mode I'm running in. Fall back to local by default, but maybe find

4:29

Speaker 2: uh staging or production when we move to staging and production. Also, you can pull apart and compose your settings in multiple classes. So you might have your Redis settings and then then just say okay here are my Redis settings that all the settings are kept together now I want to re mix them into my development settings and so on. Uh It also supports environment variables. So you can decorate your your a method to say this is an environment variable. It'll use the name of the method to decide which environment variable to get, or you can prefix it as well to say. Put Django on the front of it. Additionally, you can specify the type you want it cast to, and that can be any callable to determine how to read it.

5:15

Speaker 2: Then sometime later I came up with a a thing at work that stumped me that I needed a much cleaner way of describing configuration and this was outside the context of Django. We didn't just need a setting. file. And so I came up with Confucius because since that time Python 3 had come along and Python 3 has type annotations. We love type annotations, don't we? Don't we? Yes. I know Tom does. So here's the here's the basic idea with Confucius. You import the base config and from that you subclass your config Then you go and define your default values and their types. And it will do the work for you of pulling them out of the environment if they're defined, casting them to the type that you've said

6:03

Speaker 2: and giving them to you when you need them. And you use it just simply like a constant. It's actually a singleton pattern defined in Python. I know people don't like that. Too bad. Your config is a singleton. Let's let's admit it. Additionally, here's how examples of using it come from the README. You can just go and run it and You can override your port. And here we see it's nicely typing Y to be yes, to be true, so that we don't have to think about that sort of thing. How do we use that with Django? Well it's a little more clumsy than the other version, but it's actually doing exactly the same thing as

6:49

Speaker 2: Class-based settings was doing, Django Classy Settings. Or Hands up who's using Python 3. 7. Does anybody know now that your modules in 3. 7 can have a Dunder getAtter? It will produce a getAtter function for you that will look itself up for whatever you need, which means that anything you don't define in your settings class will be looked up in your config class. And of course, all your config objects can also have methods that refer to themselves to pull out their own values. If you don't agree with me, come and point out why I'm wrong. At the sprints, of course. You're all coming to the sprints, right?

7:36

Speaker 2: Okay, thank you.

7:38

Speaker 1: Thank you. David Our next speaker is David. So our time is here, so you can have a look always there and know where you which time where you are at Right, so I also wanted to talk about Africa, right? Since we came all the way anyway. Right, so a little bit of the history about PyCon Africa or PyCon in Africa Oh, we are here. I'll continue in just a few minutes.

8:16

Speaker 3: Right, hello. Um my name is David. I work for Octopus Energy who are a new renewable energy supplier in the UK. And um I want to talk to you about heretical Django practice that we follow, which is quite I think is quite useful for everybody. Uh actually follows on really nicely from a little section of Tom's talk and also from the uh the talk earlier on about uh the 10,000 uh commit. Django project and the challenges that come with that. So a bit of context, we all we two also have a massive uh Django kind of mono repo, like 40,000 commits, two and a half thousand migrations. We've been working on it for kind of three years. We've got to the point where we're kind of outgrowing Django, or some parts of it at least. So some of the things that are super useful when you get started, you're trying to build things quickly, kind of model forms, the admin. uh things like that are starting to kind of hold us back in a way.

9:03

Speaker 3: We want to enforce certain kind of architectural rules and layers and some of these things that kind of cross concerns a little bit. We've started to kind of phase them out And so we've come up with a whole suite of kind of fairly heretical conventions that we find really useful. And we have them published in a public uh style guide that you can visit. But let's have a look at one of them, which I think is quite interesting. And that is to only pass Python primitives to your templates. So that means that what you're passing has got to be just things that will serialize to JSON, really. So strings, ints, floats. You can't pass model instances under this. kind of convention or query sets. Okay. So let's just expand a little bit on how you do that before we examine why. So if you have a view class, you've got to get context method responsible for returning this

9:50

Speaker 3: dictionary. And in that method you need to uh serialize every kind of domain object, which typically is a model instance or query set. But in in our case and other projects we have other domain objects floating around, kind of data classes, that kind of thing. And the best way to do that is to use a serializer from the Django REST framework, because that is what they're really good at doing. Taking objects and turn them in turning them into Python primitives that you can then serialize to JSON. So let's quickly walk through uh example view. So say you were writing a website for a DjangoCon like this, and you want to uh have a page which lists all the talks. So you've got a talk model. You have a list view like this, uh very conventional, but in your get context data. Uh let's quickly walk through it. So the first thing we're going to do is we're going to pop off the object list

10:35

Speaker 3: item, which is the query set, and we're popping it off to ensure we don't actually pass object list into the uh into the template. And then we're going to pass that into some template serializer class, which I'll show on the next slide. And this is just standard Django Vest framework serializer where we pass the query set as instance. And say many equals true in this case, but if you had a detailed view, you wouldn't need to use the many equals true part. And then we just write that data into the context and return Very straightforward. And this is what a template serializer looks like. This is just a standard uh Django REST framework serializer. You could have a model-based one if you like. And we're just kind of popping off uh attributes or just reading attributes straight off the instances that has been passed in, or you can walk down into its related models and grab things off there. You can comp core methods off the instance itself or core methods that you define on your serializer.

11:22

Speaker 3: And then you have a a normal template where you're just uh you're now just dealing with kind of Python primitives. You're not allowed there's no model, no model methods there Okay, so that's that's the practice. And now why would you do this kind of strange uh practice? Because it's quite unconventional. You know, new Django developers joining your team will be confused by this practice. that they've never seen before. It's quite verbose. You're writing quite a lot of code in your kind of view class that you never had to use to before. You know, you can write view classes in Django that are incredibly concise. It's more work up front. So the biggest reason is it avoids the temptation to bundle application logic, business logic, onto your models. I've seen this time and time again over the five or six years I've been writing Django and it annoys me quite a lot. So it's where you end up, like Tom said, where

12:08

Speaker 3: you've got a nice list view, but somehow you've ended up calling all these model methods that make kind of 15 SQL queries in a network call and somehow your and this is why your page is now taking 30 seconds to load. You can't do that when you use this pattern because you're forced to explicitly do all your I. O. up front. This has been annoying me so much that I wrote a snarky blog article called Why Your Django Models Are Fat. And so uh just to expand on that, so we've got this explicit I. O. which is really useful. Because you've pre-computed all your template context, it's a really nice hook point to cache. those variables or maybe to compu compute some aggregate variables, kind of um what um kind of statistics that apply to the the whole list of things you're passing in. And it's actually a really nice step towards converting your view into a kind of REST API. That's certainly part of our strategy at Octopus

12:53

Speaker 3: is to slowly convert some of our existing Django views into kind of REST APIs or GraphQL APIs. And you already kind of get got your serializer that does it for you. So you're you're virtually there. And so to take away from this, Django REST Framework server layers are super useful, not just in the context of actually writing a Django, uh sorry, writing a REST framework kind of view. This pattern of serializing template contacts can be useful, mainly if you're a large application that's been going on for a long time, and then starting to outgrow Django. And please have a look at our other conventions because there's lots of other useful.

13:24

Speaker 1: Thank you. Andrew. Andrew Andrew is our next speaker. Something is wrong with Mm. This one, this one. Try turning off. Okay. It's not working. Is it? Okay.

13:55

Speaker 4: There we go. All right. Hello everyone. I'm here to talk to you about asynchronous real-time programming in space, very importantly. Um so in particular, uh a very certain part of space, this, this is the lunar lander. If you've not seen it, it went to the moon quite a while ago now. Um but the important part of it is, because we are computer programmers, this. This is the Apollo guidance computer. It has a whopping four kilobytes of memory. Ooh. It weighs 30 kilograms and the only interface is that tiny thing there on the side, the disk key, the display and key interface. Now, there's a particular part of this computer called the PINGS, which of course, being NASA is a long acrocon M4, the primary guidance navigation and control system. Crucially, the Apollo lander was actually partially computer controlled.

14:44

Speaker 4: It was sort of an autopilot that took them down onto the moon's surface. And when it was running that approach program, it was like reading the surface radar, working out how fast it was going, plotting the courses, that took the tiny little processor in the Apollo guidance computer to about 85% load And so they're like, well, you know, that's pretty good. That's a good headroom we have on that. We're pretty happy with that as a safety margin. And then at some point in the descent, um the astronauts wanted to use a bit more. They wanted to know, well, how how high are we, how how quickly are we approaching. So they turned on command 1668 delta H how high are we? Um that adds 10% extra load. So if we're keeping track, 95% load. Still great. Processor is very happy. Everything's going really lovely.

15:31

Speaker 4: This, however, is the problem. Uh this is the rendezvous radar for the lunar lander. It points at the other bit of the um mission that orbits the moon, works out where it is, and tries to keep track of it Now in all the testing, it was fine. And then they went to production and things weren't fine. Specifically, what they did in the real Lunalander is they hooked up that antenna to a different 800 MHz source to the one the computer was using to run itself. If you've ever done anything with frequencies to know this is a very bad idea. What happened was the radar went out of sync and started seeing the command module phase in and out of existence and get very confused. And what this means is it kept interrupting the QUD going, I've lost it, I've got it, I've lost it, and just using up extra cycles.

16:19

Speaker 4: In fact, 13 % of cycles. Now, if you're not good at maths, um that is 108% of the CPU. Uh that's not good. Now crucially, this would have, before we had the idea of real-time processing Completely screwed the mission. They were about to pull the abort and manually boost themselves back up off the moon, fail the moon landing, and Apollo 12 would have been an historic one. But the key thing that happened was some very very clever programmers got there first. They invented stuff that had never been used before to save that that moon landing. So the disky and the computer um raised what's called alarm 1202. What actually was happening behind the teams here is they'd written the very first real-time scheduler for this

17:04

Speaker 4: tiny little computer. It had a series of programs. The programs had priorities. It's like a normal Unix system. It's weird. And the ones with higher priorities ran first. And so what happens is like the one at the bottom here is the bit that makes you land. It's kind of important. And the one at the top is where am I? Kind of important but less important. And when you run out of CPU cycles, it doesn't just stop, it runs the ones that are important, and the ones that aren't important don't get run And so Servicer starts running and not finishing and overlapping itself and it uses up all four kilobytes of that memory, and that's what the alarm is. It's saying I've run out of memory, I have to reboot myself. Thankfully, the astronauts were sensible, knew what this meant, and they switched it to an easier version of autopilot, so they used up less cycles, the memory wasn't being overloaded, and they were all fine.

17:51

Speaker 4: But the key thing to know is this is the work of one person, Hal. Thanks, Hal. Years before Apollo 11, like the whole computer part of Apollo 11 was an afterthought. They were like, well The computer's probably important and navigation probably is, but Hal will take care of it. Um he invented the boxcar executive, which is The literal current still state of the art in real-time programming. It does this priority scheduling. It understands that he sorry he didn't read it. This is the old one. My mistake. This one is bad. This one has a fixed time allocation If they were running this, the moon landing would have failed. He invented the new one, the new executive. Um he made that system up from scratch. It is still that design that they use in in the 60s is still state-of-the-art for modern spacecraft today.

18:38

Speaker 4: And so it's an amazing story of just predicting and doing great engineering from scratch, working up a whole new idea and starting the whole beginning of real-time programming. And if you want to know more tales than this and many other things that really did not go well on the moon missions, there's a great website here where you can read about them. Thank you very much.

19:03

Speaker 1: Thank you, Andrew. Check this myself. Okay, thank you. So our next speaker is Tom. And yes, our little story about Africa. So Python in Africa started showing activity in twenty ten and twenty eleven and this happened in South Africa, Kenya and Cameroon. And uh for the next four years, um PSF only got funding for PyCon South Africa, so there was no other activity shown within that time. Um so we are ready for our next speaker.

19:36

Speaker 5: All right. Can you hear me? Hello? Yeah. Okay. Um all right. I uh built a thing called um DState uh Machina. uh which is uh yet another state machine uh for Django and I'm trying to solve uh race conditions in concurrent model updates with that because everybody has the same problems in their models when doing just about anything in Django. So uh again, hi, uh I'm Tom Ballrod and I work at Tia, like one of the scootest companies that you might have seen down uh like on the road and uh we are hiring And uh so nobody uh likes race conditions. And uh so um race conditions happen all the time to everybody using Django.

20:23

Speaker 5: Maybe they don't know it, but they happen So if you run Django in multiple processes or if you run them on multiple servers, or if you have uh background tasks like uh salary or other task worker cues. Um Then you'll have race conditions in your code because the same code is going to be executed in multiple threads at the same time. So whenever you aren't single-threaded essentially. So uh for to have an example, we've got like this this cat, this uh Schrdinger cat, which has uh three states. It might be alive, dead, or unknown, and there are two straight transitions for that cat. So uh we've got like survive or rip uh as uh state transitions and we check if the state is unknown before we go in a state

21:11

Speaker 5: because like going from alive um like going from dead to alive wouldn't make any sense, right? So uh the problem with this code is that at the moment that that we checked the state, um it could have changed in the database already. So um we gotta make sure that this doesn't happen. So what we could do is just to like grab it in a transaction, uh call a database lock and make sure that the state now is uh is um the same in the database. But the problem is that we still uh have erase condition here because like the self is cached like it's a it's the local cache of uh what has been in the database before. So um

21:56

Speaker 5: we still have the same problem as before. So we have to like after we acquire that lock we have to reread the model from the database to get where we want to be And now we're kinda safe, but this isn't threat safe yet, and it's like it's kind of a hassle to get this right. And so I uh uh um build dear state machina and you can just uh import it and uh use it in your code. So this is what it would look like. This is a state machine for the cat and you would uh wrap all your states in like this uh state instance and your state transitions would be uh just uh um methods on the on the state machine. And you can uh create your state machine uh transitions using those transitions where you just like

22:45

Speaker 5: you go uh and say, okay, from unknown to alive. This would be the survive transition, right? Or from unknown to dead, this would be the rip transition. And to use this in your model, you can then uh instead of having all the code in your model, you would just have the state machine uh with a new state machine field in your model and reference the uh um the state uh field that is the integer field as it used to be before And so for the usage, you would just call those methods on the state machine and it would do all the stuff automatically for you. It would check uh if the is it's the in the right state to be uh able to transition and so on

23:32

Speaker 5: So uh what's different between what we had before and what we have now is like uh there's no safe call because if you do a state transition, you want to have it persisted in your database. So you do or do not Uh there's not try. And uh what's also different is that there's no state checking. So if you want to call that survive call You can be sure that you are in the state unknown for the cat and uh you don't have to make that chat check for yourself. So uh in a nutshell, what this thing provides for you is like you have a state uh machine in one place. Uh this is where you keep all your model transitions, like the the changes of your model uh

24:17

Speaker 5: you wouldn't call save manually anymore. And uh the state transitions also define how your model is changed. So you know when a certain field is changed, you know it is part of that state transition, for example. It's Very practical for now for debugging for example. And of course we have no more race conditions. So uh Check out the code. It's uh on Gip GitHub and uh in the PyPy uh repository. And uh yeah, so um hope you'll enjoy that

24:54

Speaker 1: Okay, thank you, Tom Right, so there has been a change of things a little bit. So our our speech to text translators are not going to be with us for the rest of the night. They have to catch a flight I know. So um there's a little bit of a twist also in our lightning talks. Before we continue with the next speaker, we have a little surprise for you. So we are about to welcome Michel. He is going to do a little performance for us, and he has been with the school for a year now. And he's amazing at what he does. So he's about to show us how good he really is.

25:47

Speaker 1: Right, so around the party venue there are also food places that you can go to and have some food before the con before the party So you can go to a hotel and leave your laptop and stuff and still come back around the venue and have something to eat. Okay, let's give the stage to Miko.

26:42

Speaker 1: Um level. Well I haven't thought about the book. Yeah.

27:49

Speaker 1: We need what is women.

29:24

Speaker 1: Oh my god , we get the uh

30:53

Speaker 6: I'm never confused.

31:16

Speaker 1: I must say I love a folk. Benjamin, you have to come back here. Right So back to PyCon in Africa. Right. So I said for the next four years since twenty ten only South Africa received funding. So that's our first conference in Africa. It was SpyCon af uh South Africa Then in twenty fifteen Pacqua Namibia was the next conference in Africa. Uh Daniele, where are you?

32:01

Speaker 1: He is the special person to Namibia because he helped bring PyCon to Namibia. Thank you, Daniele. Are we ready? Right, in 2016 we saw more development in Africa and we saw PICON Zimbabwe and PICON Nigeria as well. Followed by that was PyCon Ghana and then PyCon Kenya. And now the next one that we really are looking forward to is PyCon Africa. in August. So I will be there. I don't know about you.

32:47

Speaker 1: But I will definitely be there. So are we ready? No no no don't worry. I have more stuff about Africa. Right, so a few facts about these beautiful countries in just a few minutes. Yes. Oops.

33:13

Speaker 7: Oh, I have no control over to Okay, awesome.

33:21

Speaker 1: Right.

33:21

Speaker 7: Sorry for the delay. Um yeah. My name is Horsh Bimjani and I'm a full-stack developer at uh Ambient Innovation. And I'm here to talk about managing Elasticsearch in Django like a pro. So if uh you had a chance to use uh integrate search in your Django project using Elasticsearch, you may have come across This package, Django hashtag, it's quite popular, very easy to use, tons of features. Well, up it it's it is It has a great ORM for uh like uh quelling the elastic search and has a lot of different management, data management features like updating the index, rebuild rebuilding the index. And uh yeah, so there's a

34:08

Speaker 7: there's a very good amount of data flow in there. But it has a problem. It is not quite updated to the to the latest version of Elasticsearch. Uh To be to be honest, it's like very bad. And uh yeah, so it supports like Elasticsearch less than 2. 0 and current version of Elasticsearch is kind of 7. 0 So we have to find an alternative. Well thankfully there is another package that does that. Uh this Elasticsearch DSL. Well this this is this kind of a uh high-level Python client which is provided by Elastic themselves. Which uh provides a nice beautiful ORM for us, but we still have to kind of manage the data by ourselves.

34:53

Speaker 7: Let's take a look at it. Uh how uh what's how is the ORM for it Well this is some uh somewhat uh looks like uh uh basic Elasticsearch query. Elasticsearch you can uh in Elasticsearch you have to kind of like uh send and receive requests using Rust API, so everything is via JSON. But Elasticsearch DSL does this nice ORM for us. So it's quite very easy to use. And it has a like very similar to the raw query of Elasticsearch format. So it's pretty nice. But we still have to figure out the problem for the data flow, which Haystack provides us and it's quite nice and this thing la lacks it. So I decided to uh build a management system for myself.

35:39

Speaker 7: Well, uh let's take a look at the in uh creating the index. Uh this is this is kind of uh uh very similar format to your uh Django REST framework serializer. Or in that we usually inherit from uh the different uh elastic uh different uh superclass that is provided for by Elasticsearch DSL. But in this case, we inherit from a superclass that I created in the abstract index. We are not going to go deeper into that, which kind of lot of lot of logic. So this is how it is done. But we have a new feature here. This it's called get updated field. Well this one you have to provide uh A date time field of your model and it will like

36:26

Speaker 7: index only the data that was like updated in the last hour or two hours or whatever. So this is kind of the management command that that it provides. Uh you can uh index the document, update the document. specify which index you want to create uh uh update or clear the index or the the age factor in that which will uh use the updated field that you provide it will and it will um Uh only update the posts that were created in the last one or two hours. So and the whole implementation of this is I I didn't have much time to create a A very open source package for it, kind of fork of uh fork of this, which depends on Elasticsearch DSL.

37:11

Speaker 7: So I created an article for it. You can just search for it and it's quite popular one. So you may be able to find the whole implementation there, including the abstract index code. And thank you.

37:33

Speaker 1: Thanks Hash. Right. So a few facts about Africa. I'll start with Ghana. Ghana is a country in West Africa. It shares borders with Ivory Coast, Burkina Faso, and Togo. Ghana has over 28 million people. And seventy percent of the population are Christians. Ghana gained independence on the sixth of March 1957. It has about eighty languages spoken. Ghana has over seventy ethnic groups

38:21

Speaker 1: And we are almost there. Don't be I have more countries. Nigeria Nigeria is in West Africa. It has over 200 million people. I come from a 2. 5 million country, so I don't know how 200 million people can live in one country. I can imagine the traffic. Nigeria shares border with uh Niger, Chad, Cameroon, Benin, and the Atlantic Ocean.

39:08

Speaker 1: It has five hundred and twenty-one languages. That's crazy. Nine of them are extinct extinct, by the way It has more than fifty percent of Muslim and it has over two hundred and fifty ethnic groups We another country Zimbabwe, my neighbor, we're skipping the Are we? Are you sure? I have more countries on my list.

39:55

Speaker 1: Okay. Right, Zimbabwe. It's in Southern Africa. It has over sixteen point five million people. One of the amazing tourist attraction places is Zambezi River and Victoria Falls. You can see Zambezi River from Namibia as well. The former president Robert Mugabe ruled from 1987 to 2017 when he resigned. That's a long time. English is the main language. They have sixteen official languages, and seventy percent of the people speak Shona.

40:46

Speaker 1: Okay.

40:47

Speaker 8: Oh actually yes. One more minute, sorry.

40:53

Speaker 1: I'm running out of Africa. Right. Cameroon Cameroon is in Central Africa, one of those countries that I want to visit as well because it's a bit special. It has more than 25 million people The official languages are French and English. So in the north, the north part gained independence from France in 1960. And then the southern part of Cameroon gained independence from Britain in nineteen sixty one. I guess this country had a lot of interest because it was colonized by two different countries.

41:43

Speaker 1: I mean , are we there yet? So Cameroon has Catholics, Protestants, and Muslims, with Catholics being more than forty percent as the minority And they have approximately two hundred and fifty languages as well. And yeah, all right. Go ahead.

42:19

Speaker 8: Cool. Hello, everybody. Uh my name is Rafael Aguilo. I work for a nonprofit organization called Learning Equality, and we build educational technology to empower learners and teachers. And today I'm going to be talking about Django for Social Good. Specifically, I'm going to be talking about our main product, Calibri. The word Calibri might sound familiar to some of you because it actually means hummingbird in a variety of different languages. And the hummingbird is a symbol of strength, hope, and migration. So here we have a picture of Jonathan who lives in the mountains of Guatemala. He's a smart and curious student, but he has a problem. He doesn't have access to resources for a high-quality education.

43:05

Speaker 8: But Jonathan is not alone. Over one in three children lack access to a quality education. Um so yeah, like I was saying, Jonathan is not alone in that. And so There's a wealth of educational technology that is available online, but over half of the world is still offline. So that means that there's over 400 million children who could benefit from technologies like Calibri. Calibri doesn't fly alone though. We have an ecosystem of products to go along with Calibri. We have Calibri Studio, which is an online repository of educational resources. We have Calibri Toolkit. which are r is a resource for teachers and implementers um to effectively use Calibri in the classroom.

43:59

Speaker 8: And the best part about this is that it's free and open source. And uh I'll put the link to the to the repo at the the end of the slides. And of course it uses Django and Django Rest framework for the back end. So we take openly licensed educational resources and we uh make them importable into Kaliri so that learners can use and access them. So our goal is to uh to have uh Calibri run on legacy hardware or low-cost devices like the Raspberry Pi. So we have uh uh various different methods to install it. We have PEX, we have pip install, we have Debian installer, we have Windows installer. So we really want to make this uh software

44:45

Speaker 8: um as as easy to access as possible. And another great part is that you don't need internet to to run the software. So You download it once over a connection and then you can have it forever. And so uh the software is designed to run without an interconnect internet connection, but when uh we do have a connection we do try to make use of that by downloading use as usage metrics. So these are some of the common use cases that Calibri can be used in prisons, in refugee camps, or rural areas. For example, someone can take a Raspberry Pi and load Calibri and content on it and go, let's say, 200 kilometers to a faraway village and They they also bring client devices for the students to

45:32

Speaker 8: use and then they can um access this this content, these this high quality content. And so go ahead, take your phones out, take a picture, or punch it in, uh enter it into your browser. Um, but just some closing remarks. So The reason we're able to build this software is because it's based already on open source software on Django. So it's I think it's amazing that something that was designed to be a CMS can be repurposed to benefit society like this. And so the next time you you come up with an idea or a project Um so yeah, the next time you come up with an idea or project, don't try to make the next big social media network.

46:18

Speaker 8: I don't want to have to make another social media account. I don't want to see pictures of your cats or dogs. Uh instead I want you to try to come up with something that will benefit the lives of people who need it most. I like to think of programming as a superpower where you can Build anything that you can imagine. So I say use this superpower so that you can be a superhero to someone like Jonathan. Thank you.

46:55

Speaker 1: Thanks, Rafael. I would like to call upon Cato. Sorry. Yeah, Carlton to come and tell us a little bit amo about the sprints.

47:23

Speaker 7: Hello.

47:24

Speaker 1: Okay. So

47:26

Speaker 7: come do the practical. The sprints. Um what are the sprints? The sprints are your oh hang on, I skipped one. Your chance to get involved, okay? Um the

47:35

Speaker 5: the pony's hungry. Um so first of all, uh where are they? They're at the Kultur Hussat in Dubai Um that's there. You can look that up on the website. When you go to the website, there are two addresses. One is here and one is the sprint venue. I found this out on Wednesday when I went to the sprint venue So

47:58

Speaker 6: here's a little here's a Google map. This one here is the sprint venue.

48:02

Speaker 5: Check when you put it into your map that it's next to that big lake there, and then go there. Don't come here. Right, what are the sprints? The sprints are an opportunity for us to get together, they're an opportunity for us to talk about problems, and they're an opportunity for us to solve them. Okay, that's it. Um you could write docs, you could fix bugs, you could help triage tickets, you could do that in Python, or not. You could work on something that wasn't software related at all, like a community project of some kind. Right? You could work on anything. You don't have to know. Right, there are some people who know what they're gonna work at at the sprint at the sprints and they'll say at the beginning of the day, I'm gonna work on this any moment to help me. If you don't know what you want to work on

48:47

Speaker 5: now, that's fine. Come and we'll help you find something to work on Okay? Um I'm gonna be there all day.

48:53

Speaker 8: I'm my main focus is gonna be on helping people. So come.

48:57

Speaker 7: You can do it. Okay? If you've never contributed to Django before, the sprints are the perfect opportunity to get involved. So please come along, please join in and let's do it. Let's feed the pony. Thanks.

49:11

Speaker 1: Thank you. Right, so we have come to the end of things, come to the end of Django Kore

Questions this talk answers

How should Django settings and environment variables be organized?

The speaker recommends keeping configuration structured in class-based settings or typed configuration objects, while still reading environment variables and providing safe fallback defaults so development or staging cannot accidentally use production resources.

Discussed at 2:09

What is Confucius and how does it handle Python configuration?

Confucius is a typed configuration system that uses Python 3 type annotations to define defaults, load overrides from the environment, cast values to the declared types, and expose the result as a singleton-like configuration object.

Discussed at 5:15

Why pass only primitive values to Django templates?

Passing only JSON-serializable primitives prevents templates from calling model methods or triggering hidden database queries. It forces database work and serialization to happen explicitly in the view, making caching and eventual conversion to a REST or GraphQL API easier.

Discussed at 11:22

How did the Apollo guidance computer handle CPU overload during the moon landing?

Its real-time scheduler used priorities: essential landing tasks continued to run while less important tasks were skipped when the computer was overloaded. The resulting 1202 alarm alerted the astronauts, who switched to a less demanding guidance mode and completed the landing.

Discussed at 16:19

How can Django model race conditions be prevented during concurrent state changes?

The speaker’s state-machine library wraps model transitions in the necessary transaction and locking logic, rereads the current database state, validates the transition, and persists it automatically instead of relying on unsafe checks followed by a normal save.

Discussed at 21:56

How can Elasticsearch be managed in a modern Django project?

Because Django Haystack does not support current Elasticsearch versions well, the speaker recommends Elasticsearch DSL for its Python ORM-like client and adds management commands and index classes to create, update, clear, and incrementally rebuild indexes.

Discussed at 34:08

How does Calibri provide educational content without internet access?

Calibri is free, open-source Django-based educational software that can be installed on low-cost or legacy hardware such as a Raspberry Pi. Content is downloaded once and then used offline in places such as rural communities, refugee camps, or prisons.

Discussed at 43:59

What are Django sprints and how can beginners participate?

Sprints are collaborative sessions where people can fix bugs, write documentation, triage tickets, or work on community projects. Beginners do not need to know what to work on in advance because experienced contributors can help them find a suitable task.

Discussed at 48:02

Note: We understand that names change, people change, and bodies change. We respect each individual's journey and privacy. If you have any concerns about a video or need us to remove content, please don't hesitate to contact us. We will handle your request with care and promptly address any issues.

More videos from DjangoCon Europe