Day 2 Lightning Talks

This video features Antonis Kalipetis, Becky Smith, Cheuk Ting Ho, Eshwari Chandashkar, Kaisa Lepajoe, Lautaro Bringar, Oluwafemi Tairu, Paul Gilmartin, Rachel Willmer, Sage Abdullah and Sasha Romijin at DjangoCon Europe 2023 in Edinburgh, Scotland.

Day 2 Lightning Talks
0:57:58
Published June 7, 2023
391 views

Lightning talks from DjangoCon Europe, 30th May 2023
https://pretalx.com/djangocon-europe-2023/talk/PL7KZT/

"But I'm not even a developer!"
A speedrun through developer as an identity and what that means, if anything.
by Sasha Romijin
https://youtu.be/siV3XfM3OEk?t=2

Let's talk about sustainability
Let's talk about the what, why, and how to be sustainable as developers.
by Oluwafemi Tairu
https://youtu.be/siV3XfM3OEk?t=348

Demystifying Django
Unreaveling project detection requirements and deployment. How we can understand the structure of your project and create the config to deploy it at platform.sh.
by Antonis Kalipetis
https://youtu.be/siV3XfM3OEk?t=672

Fast API: zero to the moon
Lessons I learnt running FastAPI in production.
by Lautaro Bringar
https://youtu.be/siV3XfM3OEk?t=971

An easter egg in Django's logo
by Sage Abdullah
https://youtu.be/siV3XfM3OEk?t=1211

Django Trade Secrets
Simple techniques newbies can use while bulding their django application: Managing settings, logging queries, SSH tunneling to QA databases, merge migrations.
by Eshwari Chandashkar
https://youtu.be/siV3XfM3OEk?t=1512

Coding your health
Clinical codes, OpenCodelists and the weird world of SNOMED-CT
by Becky Smith
https://youtu.be/siV3XfM3OEk?t=1891

The Trigger-Notify Pattern in Django
Via simple example, we introduce a django abstraction of Postgres' trigger-notify pattern as a replacement for signals + celery.
by Paul Gilmartin
https://youtu.be/siV3XfM3OEk?t=2229

Why old tech matters and why young tech people should care
by Rachel Willmer
https://youtu.be/siV3XfM3OEk?t=2613

Using the Flow State of burnout recovery
Optimising for Flow (feeling "in the zone") helps recover from burnout better than the rest.
by Kaisa Lepajoe
https://youtu.be/siV3XfM3OEk?t=2889

What is CRA?
Cyber Resilience Act is a new European regulation that require a EC step on all stoftware. Would that affect the open source software that we use every day, like Django? let's find out!.
by Cheuk Ting Ho
https://youtu.be/siV3XfM3OEk?t=3164

Summary

The speakers covered a wide range of practical and reflective topics: rejecting the idea that only programmers are “real developers,” considering sustainability in everyday technical and consumer choices, and using tooling to generate deployment configuration for Django projects. Other talks shared production lessons from FastAPI, including load-balancer timeouts and deployment configuration; an Easter egg in Django’s logo; ways to organize settings, inspect ORM-generated SQL, and use SSH tunneling; and OpenCodelists, a Django application for maintaining reproducible clinical code lists. The final talks explained how PostgreSQL triggers and LISTEN/NOTIFY can provide an asynchronous alternative to signals and Celery, and argued that old technology and the people who understand it remain important because legacy systems can still be business-critical.

Key takeaways

  • Technical identity is broader than writing code, and customer success, documentation, support, finance, and other roles are essential to making software useful.
  • Developers can reduce environmental impact by using less energy and water, reusing equipment, recycling, travelling less, and buying only what they need.
  • A deployment initializer can inspect a Django project’s structure and dependencies to generate platform configuration, including database, Redis, Poetry, static files, and migration settings.
  • FastAPI production deployments need careful attention to connection timeouts, asynchronous I/O, and whether process managers should scale behind a load balancer.
  • Django settings can be split by environment, database queries can be logged through Django’s database backend logger, and PostgreSQL triggers with LISTEN/NOTIFY can provide asynchronous database-driven callbacks.
  • Clinical coding systems contain hundreds of thousands of concepts, including surprisingly specific entries, while legacy software may remain mission-critical long after its original developers have moved on.

Summarised automatically from the transcript.

Transcript

9,454 words · auto-generated Show

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

0:06

Hi

0:06

Speaker 1: everyone. This is my 11th DownCon, I think. So I've been coming here for a while. And on Monday I was sitting next to a first timer, someone who I'd never met before, and uh they immediately angered me. Because because one of the things they said to me right away almost, they were like, oh you know, I'm not even a real developer though, you know, I'm just a customer success person in a way as if it's required Some kind of apology that they were not a real developer, someone I'd never met before. How dare they come to a DjangoCon as if it gave them less right to be there. Uh and I got very annoyed because Uh it just frustrated me that someone immediately s sort of deprecated themselves in that way because like what do you mean? Like only a customer success person?

0:53

Speaker 1: Like we need customers, they're kind of a big deal. Like we live in a capitalist society if we don't have the customers, like whatever I gonna do? And I didn't tell them because I thought if I start this rant as you and raise my voice, I don't think I'm actually helping. So Um instead I decided to deal with my anger by submitting a lightning talk and here we are. Um it also angers me because when people speak in such self-deprecating ways, like even if it's subtle, uh I also see it in some of my friends when it's not about tech at all. things that people have been taught, like they have been taught these things by other people, they have trained themselves to think this way about themselves, and it is a pet beef for me. Um so I often try to counter that when uh when I can.

1:39

Speaker 1: It's not that hard, but this one annoyed me even more because, like, what even is a real developer? Am I a real developer? Like, I don't know what does that mean. Because I am certainly not the best Python developer here. I'm not the best Rust developer, not the best JavaScript developer. I don't have never used HTMX, even though it's all the hype. Not the best at SQL I know how to spell Django correctly, so I have one step ahead of one of us here. Um maybe like Python I am the second best choice at everything. I have approximate knowledge of many things But there is so much I don't know. I don't even know about all the things I don't know and yet uh I don't know, am I still a real developer then? And What do I even do with that? And I think some of our feeling as a developers that we sometimes have a superiority, I feel a little bit of that sometimes, is that

2:30

Speaker 1: There's this idea of independence, like I can just take out a laptop, I can sit anywhere where I have internet and I can make things. Uh and in a lot of professions you can't do that. You need a lot of infrastructure, you need a lot of other resources But what do I really do all day? I just press a bunch of buttons and uh somehow that flips some bits on some storage in ways that I don't fully understand and I feel like I've tricked the rest of the world into thinking this is worth huge piles of cash. Because we get paid relatively very well. And we're not even that independent because like I mentioned before, customer success people, people who write documentation, people who answer the support desk, who do finances, they are actually all essential in uh using in in uh in making any of our work useful at all. So there is no real independence uh without the people that used

3:18

Speaker 1: and sometimes also abused our work. So am I really that more independent than my friend who works in a supermarket? They get paid minimum wage and they sell food to people, which kind of feels a lot more important than the bits I flip on a daily basis. And this has been a source of conflict in me. for for quite a while that I question what I'm doing, is there actually a point to this? Uh because all of my work is ephemeral. Like in ten years, all of it is gone, I hope Like all of it. And you know, I can be sure, but I think by the time I'm old, like I still probably have a few decades left. I don't think I'm gonna think like, you know My big regret in life is not using a factory pattern that time or being like, oh, you know, I optimized that SQL query really well. That's like the great accomplishment of my life.

4:05

Speaker 1: I'm glad that in the I don't know 60, 70, 80, 90 years that I've had, that I've contributed such things, which in the meantime have already been replaced a hundred times again. So what does that mean? I asked myself. Like are computers good or bad? Is there ethical software development under capitalism? Uh I don't actually know and I also don't know what's to do with it and I don't know if I'm ever going to figure it out. But What I came here to encourage you in this event where we like to dig down so much into the little obscure details of our field and very obscure niche things sometimes. Uh how do we get the request just half a second faster to the client? Actually that's half a second it 's way bigger than the skill we should talk about.

4:51

Speaker 1: All the little technical details that we also always remain critical of what actually matters because I don't think it's any of our code. I think rather it is the impact we have on other people. It is the products we make, how they make other people's lives better or where how they get used, how they get abused, how they Sometimes harm other people, sometimes help other people, sometimes enable them. But also the people directly around us, the people that feel that they don't belong here because they are only a customer success person and who needs customers anyways Um and so I came here to encourage you also about to think much more carefully about what we leave behind besides our code

5:37

Speaker 1: because our code is gonna be deprecated way faster than anyone can say real developer. Thank you.

5:56

Speaker 2: Okay. Um okay, so Okay, yeah, that's fine. Um I have my slides, but uh yeah, that's fine. No worries. Um sustainability. Um so I'm just here to talk about the what, why and how. Um So yeah, I'm just gonna get right into it. Um so sustainability according to Wikipedia is commonly referred to as preservation of natural resources, an ecosystem to preserve human life on earth. So essentially what can we do, what things we do to ensure that natural resources instead essentially uh

6:43

Speaker 2: um and then you're asking the question um why should i care about sustainability as a developer um Simple answer because yeah, we are humans before picking developers, so to say. So what can you do to contribute to Making the world or heads generally a better place and a condition place for us to live in. If you're lucky um the government of your country is doing something regulation wise, um companies um and all of that. But what can we as individuals do to contribute our own quota? Because at the end of the day, I feel like we humans actually emit more carbons than this some of these companies or we are sort of like um

7:28

Speaker 2: the reason why some of these companies emit a lot of carbon so essentially and and then if you care or if you feel like um there's a lot of heat or the weather recently in the UK was forating and all of that, then you probably want to care because a little bit of biology. We as humans, we give out CO2 and they retake in oxygen. The plants are supposed to take in the CO2 and then give out back oxygen. The nature sort of like finds a way to balance itself. So if there's sort of like an imbalance, then it causes a problem. So um what can we do better? Um so I have some couple of things here on how to be sustainable. Um first save water. So that could be anything around um

8:14

Speaker 2: As small as your wash loads, how you wash your clothes and all of that. Um reduce energy usage. Um so perhaps don't plug your laptop and leave it there even when it's indicating it's fully charged. You know, you could do that. Um so On a bright sunny day, perhaps turn off the lights, use energy saving bulbs, um, buy efficient or Just gadgets that use energy efficiently. Sell or donate unwanted items. Again, my size on the hot, but yeah, unwanted is sort of like in the quotes. I don't know about you, but we have some developers who line up all the sort of like all the models of a MacBook since since a long time ago or iPhones.

9:00

Speaker 2: You could say that's technically maybe not You don't need it. So perhaps just give that out. Um either trade it in, have it refurbished, send it to some part of the world where it's most likely going to be useful. Um I don't know if you heard um Sam talk yesterday about Somewhere in Nigeria in Abiyah state where some people don't have access to laptops. So if you feel like you you have a laptop that is you don't need anymore, maybe just give it out or sell it Um recycle. Yeah in the UK I know there's there's a lot of recycling going on, but just in case for anywhere in the world you high. That is not something to talk about. Maybe consider it, reduce your plastic waste and maybe go for bottles instead. Um, where you can uh use paper plates

9:45

Speaker 2: or um the ones made out of bamboo. Drive less. I feel like COVID has done a little bit. Encourage all of us to be more remote first. Um so if you necessarily don't have to go to the office maybe or if you are so like um in a place to actually take some of this things, maybe you could cut down on that, um reduce the travel, um you could use a lot of uh virtual meeting applications now there are a lot of them out there so perhaps consider using that. Purchase sustainably, purchase sustainable products, um purchase what you need. I feel like this talks to me actually as a human because I'm sort of like a gadget freak, so I try to like buy the latest and the greatest sometimes or buy some things stuff I just consider

10:30

Speaker 2: fancy. Um that's that's perhaps not too good because then again if you don't ask for those products then the manufacturing companies won't have to um sort of like manufacture them. Yeah. And yeah, um one last thing, share donate and volunteer. As much as we try, we still emit some sort of carbon and so you could give to some organizations that plant trees or you could volunteer to perhaps pick plastics out of the water or something and all of that. And yeah, that's it. Thank you.

11:12

Speaker 3: Round of applause and take it away Thank you very

11:19

Speaker 4: much and I'm glad that my screen is up there because uh I cannot sew it demo without showing something so that's at least uh I'm lucky. And it's really nice to hear talks about um uh sustainability and talks about uh inclusivity like we're all I mean we've been YAML engineers. I've been YAML engineer in the past. So potentially you've been uh the same as me. Uh so today We're going to talk about how we can understand how a Django project works and how we're approaching this platform with the tool that we've created. So a few words for me. Uh I've been working with Django for maybe ten years now, uh but at my current role we don't use Django a lot. So when the chance uh approached, uh I immediately grabbed it and um

12:05

Speaker 4: Here we are. So what we need to do is uh so before we start how many of you want to write YAML files Yeah, I I expect that. Okay, okay. Uh and just to make sure that you're not tired, how many of you like Django? Okay, so okay, you're not you're here, you're you're with me, so now we've done a bit of stretching. So uh at platforms we use YAML files to be able to configure your application and because um of course nobody likes to y write YAML files we want to make sure that you can easily deploy your application to us Uh so what we've done we uh so here I have a simple dang application. Um it's Just the start of the project, so nothing very uh interesting there. Uh and what I'm having here

12:52

Speaker 4: uh is uh I want to create the YAML files to deploy platform as a run the command called Project init. So this is a command that goes into your project and tries to understand what happens there. So immediately uh from the directory it understands this is uh this is called platform if I Django demo. Okay, that's fine And then asks me for a few services. So okay, I like Postgres. Who else does like Postgres? Okay, I w I was expecting that as well. And uh of course Redis because we need to cast things. Because uh we love it then because it saves energy so if you use gases then you use uh less compute power and less energy. So immediately this created a few files for me. Um so let's start with uh what you potentially know. So in my settings file it went and added a few more settings.

13:40

Speaker 4: So it's going to easily integrate this with uh the settings that we have and then create a new file for all the settings that I have here So for example, it understood that I have a Postgres database since I told it to, and now it's configuring things like my databases, my app platform directory. you know, all that kind of stuff that we need to to start a new Django project. But it went one step further. So uh what we did was create the file Uh and this file, so it got Python 3. 11 because this is the latest version. Everybody likes the latest stuff in there. Uh there's a lot of documentation, but I won't bother you with that. But it understood that I'm using poetry. So I'm using poetry for dependence. So it's taking a version that's recent enough, not the latest one. 1. 511 I think is the latest one.

14:26

Speaker 4: So we'll have to update that Um and also it's uh creating all the build steps. So for example it's uh it's installing Poetry initially and then using Poetry to install my dependencies. So my project will have everything it needs in there. Of course we're a Django project, so collect static is always a must. Um and then during deployment it's going to run migration. So try to understand as much as possible my uh my application. A few other interesting things. So now you see it has prefix everything with poetry so that we can run all our applications inside uh the virtual environment and also uh it identified that there is a different python path because my application is hosted in a subdirectory so it tried to to find that uh from the WISGI file and the settings file and make sure it's there. Also it's hosting my static facets in a different uh directory and serving them

15:12

Speaker 4: to sl static, so that's also good as well. And there's a few more things like my relationship and everything. But what I wanted to to say was how did we create this? So uh What we're trying to do here with we're reading your uh your files, we're looking for files like uh poetry. log to see that you're on poetry or pipemp. Peep Plock or something like that anyway. I don't remember the name for the file for pipen, you know, all that kind of stuff. And we try to identify this Django project and so on and so forth. So uh we did this with uh with Go, uh unfortunately or fortunately, uh I code a lot with Go. lately but uh it's still a nice thing and we're going to open source it pretty soon so um this is it I don't want to I will spare this extra minute but if you have any more questions if or if you find this interesting

16:00

Speaker 4: feel free to catch me later or catch us tomorrow uh our booth and thanks for being here. So this is it.

16:14

Speaker 5: Hello everyone. I am Lautaro and I'm going to talk about Fast API and experience doing it on production. So uh Fast API. We are in a Django conference, I know it, but uh it works for our use case. And I want to ask uh who is using Fast API in production Yeah, uh brave people. Uh we have uh a problem in the real world, so I want to explain why uh we choose Fast API. I was working in a warehouse management system. We ship a lot of orders and these orders need to go to a

17:00

Speaker 5: direction uh and we use uh carriers. These carriers have um API and we need to quote to get the the cheapest uh quote um and we need to run this uh as as fast as we can because time is money Our text tag was uh Fuz API, um SQL alchemy and HTTP X. Uh the that that is like a request. But I think uh our infra is in AWS uh we use the ECS service

17:46

Speaker 5: which is like a container runner uh that run uh task that inside is uh container and inside the container we have um Junicorn who span uh that is spawning uh Obicorn process. Uh we 've used the official Docker image of the five Fast API and once we Once we deploy it to production, we start seeing uh file response. And it was uh hard to debug because our application was running and on sentry we don't have um anything. And it was because we have a load balancer in front of our application.

18:33

Speaker 5: and we have a TTL uh between the user and the load balancer and the load balancer with the application. Um because Our official um Docker image have a default CTL that was lower than our uh TTL from the user and the load balancer, the connection was down and that uh the load balancer didn't know what to do and the response was five five of two Um the solution was easy, just to increase the time to live of the connection between the load balancer and the application. Well, what

19:18

Speaker 5: I learned was uh we don't use the official log image um we build uh from scratch Uh the creator said in the documentation but we didn't read because we are programmers. Please all use uh async tools to do the queries and uh to hit the external uh APIs. And another thing to Another thing to notice is that the documentation says if you have a load balancer in front of your application, don't use uh Unicorn. Ubing current process and let the load balancer scale your application.

20:03

Speaker 5: Muchas gracias. Right.

20:13

Speaker 6: Okay. Okay, um, I'm Sage and I'm going to show you a small Easter egg in Django. I promise you that it's going to be quick, so I sorry. So um for those of you who don't know what an e an Easter egg is, it's a Something that's hidden in the software or video game or whatever, uh like in this image in Wikipedia, if I click on this hedgehog, it takes me to this Easter egg page. So that's an Easter egg And what I have for you is not that exciting, but before we get into that, so Django's logo. So yeah, I'm actually going to talk about an Easter egg in Django's logo, not in Django itself Django's logo is made using this font.

20:59

Speaker 6: It's called DTLProcion, made by this person called Erhard Keyser. DTL stands for Dutch Type Library. So let's try Recreating the logo with the font. It's not quite the same because if we look at the actual logo The G is slanted. Um the cap of the G is a bit slanted, but that's not the Easter egg. So Um if I just go and open the SVG file and try to look into it.

21:44

Speaker 6: So it's been made in Adobe Illustrator, so it might have been edited. So let's copy this SVG. into Figma. Um let me just and see what I'm talking about. So that's the thing. And I'm wondering whether we can fix it. So if we want to try and fix it. So the reason why is because it was manually edited to have the slanted

22:29

Speaker 6: edge right here. So if we want to fix it, we can move this handlebars for the anchors. So oh sorry. Sorry, I'm not a designer. So let's try and fix it. Right. That's more like it. But So that makes me wonder, how long has this existed? So if we go through the history of this website. Um back in 2005, before Django was even officially released

23:15

Speaker 6: We didn't have the community tab, so you cannot even download the logo. And if I try to open this image, let's see if we can get it. Uh no, it's too low resolution, you cannot see it. And it was just a GIF image. So let's move forward. Um so yeah, this was back in two thousand and five. It wasn't so Django was not even released. So back in August, um we have a community page but still no nowhere to download the logo. So But in March of 2006, we do have an option to download the logo, so let's download it.

24:01

Speaker 6: Okay, I have the file right here and let's try to put it to Figma. Okay, moment of truth. Are you ready? So my question is that I'm going to be a little bit more than a little bit of a little bit of a little bit of a little bit of a little bit of a little bit of a little bit of a little bit of a questi The question is whether to fix or not to fix on uh on the Django project. com repository, because if we take a look at this. Yeah, it's still there. So um if you think we should fix it, raise your hands up.

24:47

Speaker 6: And if you think we don't Okay. The thing is if we fix it, then we will lose this Easter egg forever, so uh I guess I'll leave it for any one of you who wants to fix it. Okay, that's a good idea. Alright, I think that's it for me. Thank you.

25:09

Speaker 3: Thank you so much. Uh

25:19

Speaker 7: hello everyone. Uh I thought I could start. by giving a brief introduction of myself and if I were to be described as a Django model instance, this is how I would look as a record in a database. My name is Ishuri, I also go by the name Isha. I'm a director of software engineering at WizOku. I would call myself as an inexperienced speaker. This is my second talk, but I don't think I have enough experience. What do I do at Bizuku? I lead a Very talented team of engineers and we build uh B2B SaaS enterprise application for helping organizations to innovate at scale. If you'd like to know a bit more about us and what we do, please feel free to find me and I'm happy to discuss further.

26:05

Speaker 7: So what am I going to talk about today? I said Django trade secrets, but then I changed my title. It's simple trade secrets. I would like to talk about things that I learned from my mentors and peers when I started my Django journey. simple tips and techniques that helped me improve my development. Three things, how can you effectively manage your settings file to become more productive? Uh how can you use Django's inbuilt um logs to understand what queries are being run under the hood and how you can use SSH tunneling to run your local code against a QA database. First thing, manage settings.

26:52

Speaker 7: What does anybody who's read the Django documentation, this is what it would say. What is a settings file? Settings files manages the configuration of your application. This is a simple hypothetical example. You probably have a function which sends notifications and Maybe you have a settings, debug settings. When you're running your application under debug settings, you just want to print the content on your console. If not, in QA environments, staging production, you're actually going to use an email provider to send emails. Um when you start learning Django and you learn the Django settings, you're trying to understand the code. What I used to do a lot was Go to dev. py, just make debug as false and see then what happens and similarly try out different settings.

27:39

Speaker 7: And sometimes you just forget that you have experimenting with settings and you Commit the code in and then it gets deployed to a Q environment, somebody complains, emails are not being sent. Yeah, I screwed up So uh this is the first thing I learned. Um you can actually organize your um settings files into a module because settings files are ultimately a Python module. So So when you bootstrap a new application, you just see a settings. py file, convert that into a settings folder. You can have different settings files for your different environments. In our team We encourage every new developer to create a setting files of their own name and then we have a gitignore file in that folder which explicit explicitly calls out which files will be checked in

28:28

Speaker 7: and everything else can be ignored. So given this setup, what will happen? You um sorry, I skipped a bit too further. Sorry This is what you do. Run your server with the minus settings parameter my setting my site. settings. And if you notice here, you will see when the Django server comes up, it talks about which settings files it is using You can also set up a settings module environment variable in your shell and then if you just do Manage. pyrun server, it's that environment variable, the module in the environment variable that's going to be used to bring up the server. You can take and improvise

29:15

Speaker 7: this a step further, create an alias for yourself, my site. and point it um basically run the command which is set up the python path, the Django settings module, uh the Wii bin, and start up, and the Django admin script, and you start your server Right? So next time you log in, my site runs server. Your application is running with your own settings file. So this is something very simple. And something that helps you develop faster. And you're experimenting the liability and not checking in bad core. The second thing I would like to talk about, I'm just unsure. Sorry. The second technique I would like to talk about is Django is very powerful as an ORM, but when you start

30:03

Speaker 7: developing and you're a new developer, you really want to know what is that SQL query that's running under the hood. Especially if you come from a different uh stack, like it's it's like I know this is how I want to write the SQL query, but what is the ORM won't asking me to do There's great tools. Uh there is Django debug toolbar, there's Django Silk that we all use, but there's something even more simpler. You can actually use set up your logger such that The logging that's happening in Django's DB backend, you will uh see those print statements on your console. So in this in this code, if you see, I've basically set up a logger for Django. db. backends to print the debug

30:48

Speaker 7: statements. on our console and it happens only in the debug environment. So when your settings file has debug equal to false. With this, if you see now when you start up your server, you see a SQL query come up with a timing. And then if you shell and try to run some query, you'll see what's the back end query that is running. You start seeing the sprint statements. You can improvise, convert that handler into file handler And now it's easier for you to see hit a page what queries are running and you know what the SQL queries. Uh you can analyze that better. I think I'm probably out of time, so I'm gonna stop here Thank you very much for listening to me

31:32

Speaker 3: Conference. So Becky Smith is going to talk to us about coding your health. Thank you.

31:45

Speaker 8: Hello. I'm Becky, can I think you know that? I'm also the shortest person at this conference, which is why I'm standing here with this microphone and not there. So I I want to talk to you about clinical coding systems. When I'm not organizing DjangoCon, I'm a software developer at the Bennett Institute for Applied Data Science. We are a cross-disciplinary team of uh clinicians, academics, and professional software developers. And Amongst other things, we work on Open Safely, which is a secure analytics platform for NHS and for analyzing NHS electronic health records. Our goal is to make access to NHS patient data open, fast, and reproducible while protecting patient privacy.

32:35

Speaker 8: So, what are clinical codes? When you go and see the doctor, they enter your information into your electronic health record. And they do that using codes from a systematic coding system. One of the most commonly used is called SNOMED CT. It's a huge hierarchical catalogue of concepts containing over 500,000 codes So you might go to the doctor with a cough. They might also record it as complaining of cough. Then they'll ask you some more questions about perhaps whether you uh cough after eating or at rest or whether you're doing when when you're doing exercise. or when swallowing or when you whether you also have a fever, maybe along with that they'll record whether you have a sore throat. As well as clinical findings and disorders.

33:21

Speaker 8: uh SNOMAD has codes to allow clinicians to record uh relevant things like um places, um objects and uh Occupations. Um Open Codeless is part of the Open Safely platform. It's a Django site, it's built to allow researchers to create, share, and maintain codes, code lists. It helps with our goal of making research reproducible because it means that you can record the strategies that you use to develop a code list. It supports multiple coding systems, not just SNOMED, uh, and it handles ongoing updates to those coding systems. What do we mean by a code list? Researchers use code

34:07

Speaker 8: list to describe a particular disorder or area of clinical interest. So for example, they might be interested in adults who have a diagnosis of asthma. But there are many codes that describe asthma, and not all of them correspond to a current diagnosis. So for example, this code list um has lots of codes under the asthma category, but it's e excluding a code for childhood asthma. Open code lists lets you uh build a code list by searching for codes. Um the search strategies are stored with the code list. So here I've searched for cough and I can choose to include or exclude certain codes or categories of codes So that's all very useful and worth

34:53

Speaker 8: worthwhile. Uh but what's really interesting about SNOMED are some of the weirder bits of it. So if a clinician wants to get a new code into the UK version of SNOMED, they can go to this website and submit a request. This means there can be some somewhat unexpected things in the coding system, and the reason they're there is because a clinician sometime needed had a valid use case for them. So it has, for example, a section on casseroles, which begs the question, why? What did someone do with a casserole that required it to be entered into snow mud? Did they burn themselves with it? Did they drop it on their foot? Did they poison themselves? Why only vegetable ones? Sticking with the food theme, there is a surprisingly extensive classification of puddings

35:41

Speaker 8: Although it's strangely incomplete. So sponge pudding is classified into its narrower, very British child codes, but it has some notable omissions. Surely someone must have injured themselves with a sticky toffee pudding at least once. Sadly, there are no results for Django, but is it really surprising that Django's never hurt anyone? Some coats really make you wonder what happened to get them in there. Accidentally caught in ironing cord. I need to know more about that. There is a detailed breakdown on the different ways to trip on different things, or be intentionally tripped, and yet an oddly ambiguous standalone code for tripping.

36:30

Speaker 8: Gardening is apparently a rather dangerous pastime. Some codes could be custom made for cyclists in Edinburgh. And it's somewhat concerning that we need this depth of classification for events related to being sucked into an aircraft jet. If you're interested in learning more about the good work that we do at OpenSafely, have a look at our website, our docs, and our GitHub repos. All of our platform codes and our research code is open. Thank you very much.

37:15

Speaker 2: Hey, yeah, I'll just introduce myself. So I'm I'm Paul. I'm currently a Django developer at a Danish company, a time registration company called Intempus. uh it's a great place to work and I'll be talking about the Postgres trigger notify pattern and Django. So I just want to introduce a really simple uh Django application that we can talk about throughout the talk. So it's a simple web application where users can comment on articles and it's governed by these two models here So we want to introduce a new requirement to our application. We want to have the feature such that when someone comments on an article, the author of that article receives an email to let them know that someone's commented on it. So that's a fairly ubiquitous pattern in web development. You have some database event and then you want to invoke some callback based off of that event.

38:01

Speaker 2: So the canonical way, at least for me, to solve this problem would be to use Django signals, which allow you to invoke a callback when some action occurs. In our case, the action The action is the creation of the comment and the callback is the function to email the author of the article. So this is what it would look like using Django signal uh Django signals. You have a post-save signal which is invoked when someone creates a comment and you have the email callback which emails the article uh author. So it's a very common pattern that probably a lot of people have seen. It does have some shortcomings though. The one I mainly want to talk about right this second is the fact that the email is sent in the same thread as the comment creation. So this necessarily hampers comment performance time.

38:46

Speaker 2: And it also introduces another point of failure. So if it happened to be that the commenting is transactional, i. e. occurs in some atomic block in Django language, then an error encountered when emailing will actually roll back the comment creation So it's actually kind of reducing comment comment experience while uh adding this new feature. So really what we want to do is try and take the the emailing out of the comment creation thread, i. e. make it asynchronous. And a very common way to solve that in a Django application is to use some sort of message queue framework. So I won't go into detail, but this is roughly what the solution could look like using Celery. The essential difference is here that what our signal is still there, but our signal does not email anymore.

39:33

Speaker 2: Our signal just sends a message to a Celery application running a completely different server. or sort of different process rather and uh it takes care of the emailing for us. So that's kind of solved the men issues we mentioned before, but there's still quite a few shortcomings to this solution. So first is another issue with signals themselves. Signals can be missed.

39:54

Speaker 5: Anyone that's dealt with signals has probably found out the hard way that bulk creates and bulk actions in general, such as updates, are missed by signals. Communicating with the salary broker adds another point of failure. So whilst we've taken email and out of the thread, we've just added communicating with some other system into the thread. It's actually quite challenging operationally to add celery, especially if you want to do it for something as simple as just emailing someone And communicating with

40:19

Speaker 2: celery is not atomic with respect to the comment transaction. That can lead to a lot of interesting race conditions. So Postgres to the rescue. So the first thing I want to talk about is Postgres triggers instead of signals. So in Postgres, a trigger is basically a database function which is invoked automatically when some event such as an insert occurs. So it's a lot like a signal, but the crucial difference is that a trigger actually lives within the database. And as such, they are more robust than signals in some regards because they can't be skipped by things like bulk operations. And then I want someone to introduce uh the listen notify protocol instead of uh as an option as a lightweight alternative to set to celery.

41:07

Speaker 2: So Postgres comes with this native messaging protocol defined by two commands, listen and notify, and it allows one Postgres connection to asynchronously listen to notifications sent by another. And in this way you kind of build a basic foundations for a message queue natively in Postgres. And it's a very common pattern to notify a listening connection after some trigger is invoked and then have it processed asynchronously. And this is the notify trigger, trigger notify pattern that the talk is titled after. So this is why uh Django PG PubSub was introduced, which is essentially a library. Which does a Django abstraction of this trigger notify pattern. The main idea is to allow developers to easily write Python callbacks, which will be invoked asynchronously whenever a trigger is invoked.

41:57

Speaker 2: And really the main tenant is to be an alternative to the signal salary pattern which I introduced before and address some of the shortcomings that I've discussed. So this is again I won't go into much detail uh but this is kind of what the code will look like using Django PG PubSub. The two main components are we have this channel which essentially defines the the shape of the notification and it's the medium through which the notifications are sent, kind of. And then we have a listener. And that looks and by design it looks kind of like a post-save signal. The key difference is here that the decorator defines a trigger, so something which actually lives within the database and can't be skipped by bulk operations and the like. And the callback, which is the same as before, the email, will actually only occur, will

42:43

Speaker 2: only be called asynchronously within the listening process. So the only thing left to talk about is how we actually start the listing process. Well this actually happens just via a simple management command which comes with the library. which you can just plug in like this and then you have a dedicated listening process uh with which utilizes the multi-processing module to spin off as many subprocesses as you want. So that's just a basically a whirlwind tour of uh this this pattern. Uh if you want to read a bit more uh of this and also other libraries which interface between Postgres and Django, I would check recommend checking out the Opus 10 repo on GitHub.

43:28

Speaker 2: Thanks very much.

43:30

Speaker 3: Okay, thank you Paul.

43:39

Speaker 6: So uh I feel like a new speaker because this is the first one I've done since lockdown and I've kind of forgotten how to do it. So Bear with me.

43:47

Speaker 7: Okay, why old tech matters and why you should care.

43:50

Speaker 6: Because we spend a lot of time thinking about shiny new things at conferences like this.

43:55

Speaker 7: And as you can tell, I'm not exactly shiny

43:58

Speaker 6: in you.

43:59

Speaker 8: I've been working now for nearly 40 years

44:02

Speaker 6: and I was lucky enough my second job to start programming the internet.

44:07

Speaker 8: Which probably means that I've been doing this longer than some of you have been alive. And I'm still enjoying it. So, I

44:16

Speaker 6: gratuitously put this photo in any talk I do if I can possibly do it, because that was me

44:22

Speaker 8: Once upon a time when I had my startup.

44:29

Speaker 6: And and I have to say, I didn't look like that then either So I've done lots of things in my working life. I've been um coder, I've been a manager, startup founder, um, and I've been freelancing ever since I closed down the startup. I'm still enjoying it and I'm not retiring But many people my age are and there's a problem with that. Because I know I think it was Sasha at the beginning saying how she thought no that the code wouldn't be there in ten years' time. You will be surprised how much old code there is out there. And then when people like myself who are retiring and we are the people who understand that old code, there's going to be a problem because in some cases it's still business critical I'll tell you a quick story about that. I am say I've been a freelancer

45:13

Speaker 8: for a while. I used to have this regular job with one of the financial institutions in town. They had a pit of software running on an old bit of hardware and the hardware's about to fail

45:24

Speaker 7: and nobody knew how the software worked. But they couldn't take it out because it was mission critical. So I get kept getting the job to go in, take the re reinstall Perl on a new machine, reinstall that piece of software on that new machine. And

45:38

Speaker 8: we'd go through this cycle where they'd go, I go, great, give I've got I've got the tables, give me access to the server, I'll compile it all up, I'll be done within the day. And they'd go, No, no, we can't give you a compiler because you know we're a financial institution. We can't let you have that much access And I'd go, okay, well I can't do the job then. Anyway, this went round man and round and every few few years what would happen is

45:58

Speaker 7: I'd be asked to do the job. The guy who hired me to do the job

46:02

Speaker 8: would then retire because they got to the age where they got the redundancy package. that they wanted. The next manager didn't understand why we were doing this at all. Project would get canned and I'd go, thank you very much, here's my invoice. Over and over and over again.

46:18

Speaker 6: But people my age are say they're retiring

46:21

Speaker 7: or they're

46:22

Speaker 6: sadly they're dying. I've lost two ex-colleagues this last month alone. But the software keeps living on and it needs maintenance, it needs Replaced.

46:30

Speaker 7: So that's why I care. Why should you care?

46:34

Speaker 6: Well the the reason is there is the old code out there and there's a lot of money in old code and I'm a freelancer, so this kind of matters The businesses don't care about the shiny new things. They care about their bottom lines, they care about their profits. So if you've got fairly old software running on fairly old hardware It's an expensive problem. And as a freelancer, that's the kind of problem I like. An example of that, I don't know if anybody here remembers Russell Winderf. I met him at the PyCon. UK conferences several years ago.

47:06

Speaker 8: He got in touch once and said, Rachel, you

47:09

Speaker 6: you don't happen to know any Fortran, do you? 'Cause I've got a client who's desperate to find a p a programme who can do Fortran four, Fortran sixty six. And I went, funny you should say that. My first job was in Fortran. Sadly, I couldn't take the project on, but it would have been very, very well paid. So that's why I care about it, because it's lucrative. It's a really good way to work on on interesting projects and it's fun. Well

47:36

Speaker 7: I think it's fun.

47:38

Speaker 6: It feels more like software archaeology than software development. Because you have to understand what's going on, even when there's no documentation and nobody around who knows what

47:47

Speaker 7: 's going on So lucrative and fun. These are two of my favourite things. Put them together and it's a great way to work, which is why I'm not planning on retiring anytime soon. So that's why. Thank you. So before I start, if anyone in the audience can take a couple pictures of me from my mum, which I can send to her today, that would be great Send uh to me through Discord later. But yeah, I'll be talking about uh how to use the flow state to recover from burnout. Unfortunately, I went through a pretty bad case of burnout last year.

48:36

Speaker 7: Um My burnout was characterized by anxiety and panic attacks whenever any anyone sent me a message like, could you please do X? that it just freaked me out so much because I was so overworked and I had taken on too many responsibilities. I was also completely uninterested in work. I used to love working and I was just I just didn't want to do it anymore. In fact I wasn't really interested in anything, so it was sort of like a mild case of depression even. And I was basically incapable of doing work. I couldn't sit down and do work anymore. And I don't know how to explain it better than I I couldn't do it. There was a block in my brain, so it was um pretty bad.

49:21

Speaker 7: How many of you are familiar with the concept of flow state? That's good, that's good. I'm happy to hear that, in case you are not familiar with the concept. Flow is a state of optimal engagement and immersion in an activity characterized by a seamless and enjoyable experience. So these are two book recommendations. The first one is uh flow. This is where the term flow state comes from, and the other one is Calonyport's deep work, which talks about sort of how to apply flow to to your work in order to do like very deep and concentrated work. But flow is not just useful for productivity. It's actually it feels really good. If you look at the definition again, seamless and enjoyable experience.

50:10

Speaker 7: Does this look seamless and enjoyable to you? No, it's horrible. So I had a theory If I can get more flow in my life, then I would be happier. So I came up with a system to increase the amount of hours I spend in flow state every day, basically. So phase one was to find any activity that creates a flow state. And because I couldn't do any work, it had to be play. My activity of choice was puzzles. I also did uh horse riding and knitting, all kinds of fun activities. And I enjoyed it and I could do it for hours. Don't forget you can track and measure flow because you can measure the amount of hours you spend in flow in a flow state and you can actually set yourself little goals every week.

51:04

Speaker 7: Phase two is to slowly transition back into doing work. So you start with activities that kind of feel like work. But you can still enjoy them because you're slowly kind of getting used to working again and you're recovering from that burnout state For me, I started with writing my blog. I enjoyed writing. I could do it for hours, just time passed. Cleaning and organizing is also a good one. Reading, learning, and finally coding So I started with fun projects and then I moved on to my regular kind of day job again. And I got to the point where I enjoyed my work again and I was I was happy to go to work every day So the main things I want you to know

51:51

Speaker 7: is that resting is often not enough for burnout recovery. If you go on a an extended holiday after burning out, when you go back to work. your old problems are still waiting there. Nothing has changed really. Nothing has changed in your brain. So your strategy is not to rest, it's to get used to enjoying work again, enjoying your life again. And second, working in a flow state is good for productivity and mental health. So whenever you if you pick up those those books and and you read them, remember they always talk about productivity, like oh be super productive, but it also feels good. So optimize for flow

52:35

Speaker 6: May your life be flowy. Uh thank you.

52:46

Speaker 3: Explain why?

52:47

Speaker 7: Yeah, thank you so much Mark. You did a great job hosting the Lightning Talk. Thank you so much. Um so I will always start my talk by showing the first slide and say that it's the most important slice of the talk. And believe me, it's like it's true because

53:02

Speaker 6: every time I give this lightning talk, and if I don't put this slide and then people can't have You give a CY. Just take a picture of this slide. I'll give you a few times to take it. It's fine. We we have five minutes. It's fine.

53:15

Speaker 7: So

53:16

Speaker 6: um yeah, why we should care about the CRA on um how it can affect you and your work. So uh what is CRA? This is the very very logist uh legit question because uh first of all who have heard about CRA?

53:30

Speaker 7: Okay, there's more and more people, but still a lot of you don't know.

53:33

Speaker 6: That's why I'm asking this question and trying to answer this question. So

53:36

Speaker 7: CRA is the short form for Cyber Resilient Act.

53:41

Speaker 6: But who remember

53:42

Speaker 7: GDPR?

53:43

Speaker 6: I hope all of you have heard about GDPR and you have eat a lot of these cookies because you have to click yes uh when you go to a website. So um Yeah, now we have the Cyber Resilient Act, which is another thing that could change our life forever, just like the GDP hours, because now we have to click accept cookies. Um so uh

54:03

Speaker 7: to make it short because I I only have like five minutes or maybe like only four minutes now to explain um what is CRA.

54:10

Speaker 6: So

54:10

Speaker 7: To to put it short, it's basically like putting this logo.

54:13

Speaker 6: We have all seen this logo before. Um

54:15

Speaker 7: so it's like, you know,

54:16

Speaker 6: have a stam of approval uh on your product.

54:18

Speaker 7: For example, your

54:19

Speaker 6: kettle

54:19

Speaker 7: uh or your microwave.

54:21

Speaker 6: I don't know what else you have, but uh yeah. So

54:23

Speaker 7: now we want to put that on the software just to make sure it's safe to use. So it's a good thing, right? Because you we use software every day. It could be a malware, it could be something that like is very vulnerable and someone can hack it and steal our data or whatever.

54:37

Speaker 6: So

54:38

Speaker 7: it's a good thing, right? We want to make sure everything is safe. Um but you know, we are talking about open source here now, so um like that, you know Can that small project there got like the um approval, you know, uh to check is is it a p compliance or anything, you know. Did that dude who maintained it since 2003 get the money? Um I don't know So um yeah. Uh we we you know um we we we really can't do, you know, we don't have the money.

55:10

Speaker 6: Um

55:10

Speaker 7: so uh If you really read it, uh you actually find a link to read it later. Uh if you really read it, there's like some exception for non-commercial TFT and all this stuff, right? We we we should be fine But what is a commercial activity? Think about it. Think about for example the DSF like today we have the workshop we talk about oh how we can get more donation and stuff like now you know

55:33

Speaker 6: is

55:34

Speaker 7: accepting donation a commercial activity

55:37

Speaker 6: Um so

55:37

Speaker 7: what about if for example uh you know

55:40

Speaker 6: my uh

55:41

Speaker 7: you know your company have a product, you want to convince your company to open source this product, is it okay now? You know, maybe maybe your company will say no Um, you know, can can I work for open source during my office hour? Um can you know, can I uh you know, if I for example you're a startup company, can you like have a cloud service based on open source now? Because you know Uh so we now you have to get it approved. So um yeah, but you're a startup you don't have money, so uh strange Uh so what should I do? Like I really don't want to have all these like you know

56:14

Speaker 6: the the the product I use and love to be in trouble, you know, uh or my company will tell me stop using it because we can't get uh the compliance and stuff. So Um yeah, what should I do?

56:24

Speaker 7: It's it's quite scary.

56:26

Speaker 6: Um so I would suggest everybody, since like those of you who hasn't raised a hand before, now you can raise your hand and say that I know what is CRA and I'm gonna tell you about it So get more information and then tell people about it. Um

56:40

Speaker 7: so w uh this is Spider uh open from

56:43

Speaker 6: uh

56:43

Speaker 7: Europe.

56:44

Speaker 6: So uh They have a panel session. Uh

56:46

Speaker 7: unfortunately, if you see the video, it's like, oh, white male is a very homogeneous, but they

56:53

Speaker 6: did

56:53

Speaker 7: invite uh Deb

56:54

Speaker 6: who is like uh the the direct

56:56

Speaker 7: uh executive director of the PSF and also tried to invite me to be there but unfortunately both of us can't made it so that's why um it's like that but but yeah they they tried.

57:04

Speaker 6: So um But watch it, uh it will you get more information.

57:07

Speaker 7: Also, uh there are all these link that uh you can get more information.

57:11

Speaker 6: That's why you have to get the like

57:12

Speaker 7: the slides the link of this slide deck because you don't want to um type it all in yourself And also in EuroPython we are thinking about uh organizing and conference discussion about CRA. So if you're coming to EuroPython, you can also discuss all this stuff your concern and everything together. So um yeah we it's gonna to help uh to

57:33

Speaker 6: raise awareness and make sure that like now we can give in some like a management and make sure that everything I will be fine for us, uh or at least less damaging for us. So I think that's I'll

57:46

Speaker 8: Yes.

57:47

Speaker 3: Absolutely spot on

Questions this talk answers

What does it mean to be a “real developer”?

The speaker argues that there is no useful standard for being a “real developer”: developers have varying skills and rely on many other roles, including customer success, documentation, support, and finance. What matters more than technical status is the impact the work has on other people.

Discussed at 1:39

What should developers care about besides their code?

Developers should consider the products and systems they create, how those systems help or harm people, and whether the people around them feel included and valued. Code will be replaced, but its effects on people and society may last longer.

Discussed at 4:51

Why should developers care about sustainability?

Developers are people before they are developers, and their choices contribute to resource use and emissions. They can help improve living conditions by reducing energy and water use, avoiding unnecessary purchases, reusing or recycling equipment, travelling less, and supporting environmental organizations.

Discussed at 6:43

What are practical ways developers can work more sustainably?

Useful steps include saving water, reducing energy consumption, donating or refurbishing unwanted devices, recycling, reducing plastic waste, driving and travelling less, buying only what is needed, and sharing, donating, or volunteering for environmental causes.

Discussed at 8:14

How can a tool generate deployment configuration for a Django project?

The platform’s `project init` command examines the project files, identifies details such as Django, Poetry, the Python version, the project layout, and selected services like PostgreSQL and Redis, then generates YAML and related configuration files. It also adds settings and deployment steps such as dependency installation, static-file collection, and migrations.

Discussed at 12:52

Why did a FastAPI application return 502 errors in production?

The application was behind a load balancer, and the connection time-to-live in the official Docker image was shorter than the timeouts between the user, load balancer, and application. The connection closed unexpectedly, leaving the load balancer unable to handle the response.

Discussed at 17:33

How do you fix FastAPI 502 errors caused by connection timeouts?

Increase the connection time-to-live between the load balancer and the application. The speaker also recommends building the production image deliberately, using asynchronous tools for queries and external APIs, and letting the load balancer scale the application rather than running multiple Unicorn processes behind it.

Discussed at 18:18

How can Django settings be organized for different environments?

Turn the single `settings.py` file into a settings package containing separate modules for different environments, and optionally a personal, gitignored settings file for each developer. Run Django with the desired module using `--settings` or the `DJANGO_SETTINGS_MODULE` environment variable, and aliases can make that easy to repeat.

Discussed at 27:40

How can you see the SQL queries generated by Django’s ORM?

Configure Django’s `django.db.backends` logger to emit debug messages to the console, typically only when debugging is enabled. Django will then show the generated SQL and its timing when pages or shell queries execute; the handler can also be changed to write the output to a file.

Discussed at 30:03

What are clinical coding systems used for?

Clinical coding systems such as SNOMED CT provide standardized codes for recording diagnoses, symptoms, findings, places, objects, and other information in electronic health records. Researchers can use these codes to build reproducible code lists for conditions such as asthma.

Discussed at 32:35

How does OpenCodelists help researchers work with clinical codes?

OpenCodelists lets researchers search supported coding systems, include or exclude codes or categories, and save the search strategy alongside the resulting code list. It also supports multiple coding systems and keeps up with their ongoing updates.

Discussed at 33:32

Why use PostgreSQL triggers and LISTEN/NOTIFY instead of Django signals and Celery?

PostgreSQL triggers run in the database and are not skipped by bulk operations, while LISTEN/NOTIFY provides a lightweight asynchronous messaging mechanism. Together, they avoid doing email work in the request transaction and reduce some of the operational and race-condition problems associated with signals and a separate Celery broker.

Discussed at 40:20

How does Django PG PubSub implement asynchronous database callbacks?

The library defines a notification channel and a listener whose callback is invoked asynchronously when a database trigger fires. A management command starts the listening process and can use multiple subprocesses to handle notifications.

Discussed at 41:33

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 by Antonis Kalipetis, Becky Smith, Cheuk Ting Ho, Eshwari Chandashkar, Kaisa Lepajoe, Lautaro Bringar, Oluwafemi Tairu, Paul Gilmartin, Rachel Willmer, Sage Abdullah and Sasha Romijin

More videos from DjangoCon Europe