Back to the video

Lightning Talks Day 1

Transcript

By Speaker 1, Speaker 2, Speaker 3, Speaker 4, Speaker 5, Speaker 6, Speaker 7, Speaker 8. From DjangoCon Europe 2022. Published October 14, 2022.

Watch the video Markdown version 5,933 words · auto-generated · en

Summary

The lightning talks present practical ways to improve Django-based work. Mita describes GeoMesh, a Python/Django service that cleans noisy survey CSV data for landscape-terrain models; another speaker shows how web components can add modern form behaviour, styling, validation, uploads, and nested forms without moving business logic into a JavaScript framework. Other speakers demonstrate Colo’s request tracing and debugging, explain how mentoring and flexible language choices helped complete the Spanish Python documentation, advocate pair programming and invite contributors to conference sprints, and promote the multilingual 24-hour PyJamasCon. The remaining talks cover Django migration support for PostgreSQL functions and triggers, ongoing improvements to Django’s own full-text search, and generating Vue.js server-rendering templates ahead of time so Node.js is not needed in production for the initial response.

Transcript

Automatically transcribed, so expect mistakes in names and technical terms. Filler words are removed.

0:00 1st Talk

Speaker 1

Hi, I'm Mita and I'm a landscape architect that is also doing programming. So let me tell you something about landscape architecture. Actually, we design open space, apart from architecture, the designs buildings. And we usually make the before picture a beautiful after picture. And we use this, we do this with using 3D models, precise, exact 3D models of existing terrain. And these models help us stay on budget as well as help the contractor and the investor

to see, to know what they're gonna get out of it. So in the design process we use different 3D programs like AutoCAD, ArhuCAD. Maya, Rhino, probably most of them you've never heard, but if you have, kudos to you. So basically what we do to make these models is we get the initial terrain or the initial data from surveyors that go into the field, take a whole bunch of points, And make a plan, a map that looks like this. A couple of lines, we call them contour lines that tell the height. And

About a thousand points per project that should end up looking like this. This is just a model of the terrain, the previous one that you saw. Unfortunately, we usually get data that looks like this. These spikes, these anomalies. Are data that has no height value. And the height value is the most important thing when it comes to 3D modeling. So what we do, what I did, is make a CSV file from Archicad or AutoCAD And correct it. Delete everything that you see here in purple because that's just white noise

that makes The file for AutoCAD unreadable. So you can do this by hand. It takes about three hours, and you make a bunch of mistakes. Or you can write a program, you can write code, which I did, and named it GeoMesh. It's sort of a working title. But that basically filtered out all the unuseful data that I had that made a pretty nice 3D model. So GeoMesh is live. It's on Heroku. It's very easy to use. You just upload a CSV file, press submit, and you get a download file.

With tells you how much data you lost, so you can like correct it and or ask the surveyor to give you more data. Or maybe you're happy with it and you don't spend three hours on it and it likes to focus on the stuff that really, really matters. on the design. So and of course it's written in Python and the framework for the app is Django, but it helps you make these pretty pictures. these pretty designs. And I would be really, really grateful if anybody knows any Rhino developers or is A Rhino

developer to help me out because I really want this app to be more applicable than just to me, because currently I'm the only one that's using it. So thanks.

4:11 2nd Talk

Speaker 2

Hello. Some of you maybe will participate at the Django Girls event next Saturday. And here is a spoiler alert. In the last chapter of that tutorial, it's explained how to implement forms in Django. And there the first paragraph starts with the following statement. The final thing we want to do on our website is create a nice way to add and edit a blog post. Django's admin is cool, but it's rather hard to customize and make pretty But isn't it a pity that Django doesn't support all the nice features which have been added to modern browsers and instead still relies on pure HTTP response request cycles?

The Django Goals tutorial then shows how to start with the model for our blog posts. Note that I've added two extra fields to that model. Tags, which is a many-to-many field used to classify or blog post, an image, which optionally can be used to upload an image. Starting from this model, we create a Django form. And with Z form we create a Django view and then we render that view using a template. And finally we connect everything together by routing the URLs to those views. Now If we load our block application and start to add a new post, as we expect, Django renders a form editor for us.

What we see here are the four input fields reflecting the fields we have defined in our model. The first is an input field followed by a text area. The third field is a multiple select box. The default widget from a user experience view is really awful. The last field is used to upload an image. Here we also experience a bad usability because there's no preview and if the submitted form does not validate we have to resend the complete payload again. But there are other issues with this approach According to the Bootstrip documentation, fields should be grouped and special CSS classes shall be applied to each field and label.

To achieve this in Django, you must first add it to the form template and rewrite field by field. But we don't want to repeat ourselves. Fortunately, since Django 4. 0, we can override the class FOMRenderer which can handle this for us. In my workshop I will show how to do that not only for Bootstrap but for other CSS frameworks such as Tailwind, Bulma, Foundation or your own style guide. In a real-world application, the approach described in the Django Girls tutorial is not contemporary anymore. The typical solution would be to use one of the many JavaScript frameworks, for instance React of UGS. This, however, separates parts of the business logic between the browser and the server.

But we can achieve the same result by wrapping our form into a web component. We then get all the benefits such as immediate from validation, jumping to the first invalid field, user-friendly select fields to edit many-to-many relations. file uploads with preview, buttons to give feedback on submission success or failure. This all can be done with minimal changes to the existing code base used in the Django Girls tutorial. My workshop is based on that tutorial and I will show how to implement asynchronous file uploading and select fields with lazy lookups, but without having to specify extra endpoints. Create collection of forms. Nest collections into each other.

Create expandable lists of form collections. Adding animation and actions to the form buttons. Client-side form validation without writing JavaScript. hiding form fields and field sets depending on the current context, using various CSS frameworks. In summary, you can bring the functionality of the Django admin to the front end with the user experience of modern JavaScript frameworks, but with the simplicity of Django's well-established model -to-form -to-view approach. If you want to learn more, feel free to attend my workshop tomorrow at quarter past eleven.

Speaker 3

Thank you so much. Thank you, Jacob. Looking forward for the workshop tomorrow. Let's go to the next one.

8:47 3rd Talk

Speaker 4

All right. Hello everyone. Yeah, excited to be here. I want to say a couple of words about Django and how Colo can help you debug it. And to promote the workshop which I'm doing at 4 p. On Friday. So Colo is a novel Django debugger that helps you see every variable, every function call, and every SQL query in your in every request script or test. And that's my only slide actually because I want to live demo some stuff with you. So hopefully the live demo gods are with us today So let's see how this works. So actually for these purposes, I want us to imagine that we're a new developer on a Django code base, and in this case we're working on the Simple Paul Slack app. And we've received our first ticket, which is that whenever someone votes on a poll, like I'm doing now you should receive a you voted

message back in SAC. Now this doesn't really make sense as a feature because you know there's other ways to represent that, but I just want to make sure, or I just want to you know go through that use case with you. So if I'm a completely new developer to the code base, I don't really know where I can add this new feature. So I might have a look through, you know, the file browser. Or I might search for this string and then I can work my way back from that file to where I might want to add my new feature to send that message to the user who just voted. But with Colo, what you can do actually is you can see all the recently served requests right in your editor here. So I just clicked on I just clicked on this button here to vote. And a new request showed up, or if I click a button here, you'll see a new request will show up.

And then as soon as we have this request or this trace recorded, we can actually see a visualization of everything that happened during our request. So every node in this visualization is a function call in white or a SQL query in purple. Background jobs are in green and then we have some outbound HTTP requests as well in blue. And then as this new developer on you know this new project, I can then actually go in and explore a little bit. So without any knowledge of the code base, I can see that there's a few sort of big nodes with a lot of logic hanging off them And I can see what the functions are and I can actually click on them and jump straight to the code. So it's pretty apparent in this visualization that this vote function seems to be coordinating a lot of the work and sure enough we did cast a vote in simple poll in slack

and yes this function is actually a great place to add this feature if we actually wanted to do that So without knowing anything about the code base, I can just make a request as a new developer, or you know, as many of us do all the time when we explore a unfamiliar part of a code base we might have even worked on for a long time I can just get an overview of kind of everything that's happening and then dig in later. So that's some of the you know basic functionality that that colour provides. So you can jump straight to each function call. You can also see the local variables. And the values for them for each you know as they were during the request. So in this case, this best user ID returned this value. And I can actually click on this and see all of the local variables. In this case, they're all actually input arguments For this vote function, I can see all of the variables throughout the body of the function, and then I can see the return value as well.

In this case, it's an HTTP response. I can also see SQL queries, jump to them, and then jump to exactly where in my code they were actually called. So this is using colo in a in an HTTP request, but as of lately we've actually added a few new features. So I want to show two of them for you. So this first one I'm actually gonna jump into the shell Let me make this a little bit bigger. So we're in a shell here, and I'm going to import a few things. And also set up a config. So by default, colo just shows you the code, the user code. So code that exists that that you know exists in your project and that you wrote or that someone on your team wrote, not library code.

But we can tell it to actually include all of the work that the hard work that Django is doing for you as well. And then we can enable Colo with a conf context manager. And I'm just going to do one thing here, which is make a simple get a get query. So it's just a single select query And that way we'll see everything that Django is actually doing for us under the so all the hard work that Django is putting in as it executes this get query. So it's doing 700 different frames. So this is everything that Django is doing for us when it makes a SQL query So if you attended the talk earlier about what Django does to build up a query, some of these file names and function names might be familiar to you here. And we can actually see that

most of the time is spent on actually setting up a connection. So if we try and do this very same thing again, we should see a different value. So we see the same thing happened again, but now with just 400 frames, and we can actually compare these two.

Speaker 3

It's over.

Speaker 4

Nice.

Speaker 3

Thank you. Thank you so much. Let's go to the next one. Philip.

14:10 4th Talk

Speaker 5

Okay, hello everybody. I'm Manuel. I'm from Argentina and my mother tongue is Spanish. So and I do care about documentation. So this talk is about that, I mean the combination of those things, basically the another language that is not English and documentation. I got today I got inspired by the Kojo talk about maintainers and collaborators and contributors that are not just code, right? So there are a lot of ways of contribute to the project. And I would say maybe three years ago more or less we started this project of translating all the official Python documentation into Spanish. and it was an amazing project and I wanted to share some of the tips or some of the things that we learned

and why it succeed or I we don't really know exactly why it succeeded because I've been translating documentation I don't know, maybe seven years more or less, but this is the first time that I participate in a project that it did work and we have hundred percent translated the Python documentation into Spanish right now. So we are super happy with that. And I wanted to share some of the things that we have done and that we think that because of that it worked, right? So it took it took us like a year to complete the project and we saw that there are others other people other teams trying to do the same but they had a lot of problem and they were they never completed

The translation of the documentation. So maybe it can help other projects or other communities to do the same. We thought that a good idea to encourage people to collaborate in the project was to give them something in exchange, right? So we are asking for their team for their for the time. Because maybe they are like professional translator or because they are developer that understand Python and understand English and Spanish but we were like okay you contribute to this project and we are not giving nothing in exchange. So we started like creating some guides about how to use git what why it's important to contribute in a in an open source project right how it could be useful for

other aspect of your life basically, how you can do your first pull request and all these small things but we were like mentoring them and encouraging them to learn something that is probably not on their on their field, right? Because if they're they're We have people that were like sociologists, chemistry, translators, right? That they don't really need Git or Python or any of this stuff. So our idea was to share something that they could use in another in another way, right? We had a lot of problems at the beginning trying to discuss or agreed in what was the like the specific localization Spanish is super big and there is

Latin American Spanish, Argentinian Spanish, Mexican, Spain. So we all use like different words. It's the same language but it's they're all different words and so we try to lower down the barrier and tell them to translate the whole module in the way that they feel like comfortable with right So we try to not push them to write like in Spanish from Spain specifically through the whole model, but the Spanish that they use like day to day, so it's easier for them to write the documentation in the in the language and in the way that they feel more comfortable, right? So that reduces a lot of work because we stopped like discussing what was the best word for this particular translation, right?

But then we realized that in another module we use a different word for that because that was more colloquial in the Spanish. in this in Spanish from Spain, but it was like different in Spanish from Argentina. So we thought that if it was everything The same word was using across the whole module, that was fine. So we assign it task by per a module by person, right? So all the all the module has consistency along it. Another thing that we did was like give people like immediately after the first PR was merged or the second one. give them like admin permission to everything right so we try to mentor them immediately when they feel comfortable

to meant to them mentor other people that were also onboarding If they are right now how to use Git or how to create a pull request, how to use the desktop application that we use to translate the pod file, they should were they were like they can start mentoring other people, right? So we give them admin permission to the repository, we make them like feel more comfortable, more involved with the project.

Speaker 3

Thank you.

Speaker 5

Thank you. Bye.

19:25 5th Talk

Speaker 6

Alright, so my name is Philip and I came to you from Python Network team in Anaconda and I wanted to invite you to some pre-programming. Why I want to you N I'm not having a workshop to advertise today as the people before, but we have sprints on Saturday and Sunday, so maybe sprints a good opportunity for pre-programming And I want to tell you why it might be a good opportunity. So Ken Beck wrote once that all the code that we put into production should be written in pair And it you might consider that statement a little bit extreme

But when you look at the book when he wrote it, it's book of extreme programming, so you may expect the extreme measure. So, what I want to tell you is based on my first hand experience and only on my first hand experience I did no research. On pair programming. There is some academic research on pair programming, but you know it's often based on experiments on students, and it's not what we do. So extreme programming is what we are what we are doing in our Python and our team. So what I'm going to tell

is based on that experience. So there are some pros and cons on extra programming, but we won't be talking about cons because they're You know, lightning talk, we don't have time. So no code reviews. That's a important part of what we are doing. There are no code reviews because Wally There is no need for code reviews. On the other hand, you may tell that you are doing code review all the time when you are doing pair programming. So we have two pairs of eyes looking at the looking at the code all the time and it's easier to spot problems with two pairs of ice And there is also a conversation aspect

because programming is not only about writing code, it's about talking about what you are writing. So more or less that's what we are doing while we are doing pair programming. There is also aspect of co-knowledge transfer. We transfer knowledge about the language we are we are using, about the frameworks we are using, and about small tricks that every programmer has like some keyboard shortcut that he's using and the other person doesn't know that something is possible to So there are also many owners, many owners of the code, and

that means that if the ticket or issue is big enough to take more than one day we rotate pairs and there are multiple people working on the same issue day after day and Then you have multiple owners of the code. So on Saturday and Sunday we have sprints, so I will be very happy to do some pair programming with someone during the during the sprints. Thank you very much

23:10 6th Talk

Speaker 7

So yeah, PyJamasCon, so it's a conference that's coming up in November. What's the difference between PyDramasCon and the other conference is that we are We are very lazy. So basically why I know about PyJamas Conf in the first place is that you know we have all been there. We wake up very early in the morning for the conference Even though we may have travel like the day the night before, we haven't slept for twenty four hours, etcetera, etc, we still have to wake up and go to the conference and have coffee there. And it's so tiring sometimes. And I wonder whether we can actually have a conference that you don't need any coffee because you can just have it in your bed, right? So this is this is the idea of hijamas

con. So this is how it became in the last two years. So we have this online conference that runs for 24 hours. So no matter where you are, if you are from the other part of the world, you can still join. So it will be 24 hours marathon-ish kind of screaming. It's gonna be like a pyjamas party because we did actually have a pyjamas competition two years ago online of course so you can stay in your bed. Like some people ask me sometimes, right? Like do you have to wear pyjamas and pyjamas cone? So If your pyjamas is a conference t-shirt, you're welcome to wear any conference t-shirt that you got here or maybe in the last conference. So yeah, I can show you oh if I can

hello oh yeah so this is actually some people who actually were wearing pyjamas doing pyjamas and they take a selfie and then just join the competition it's really fun So you're welcome to do that. You can learn something about Python or just listen to some interesting talk or give a talk in PyJamas. And also, very exciting thing, we also have these this year we try something out that we welcome proposal from any languages. We already have some Spanish submission, but we still haven't got any Portuguese submission yet So we try to be multilingual. I have my friend Lise who is from Brazil, so she translated a lot for me. So that's that's really great. So We have just extended the

CFP submission deadline. Is your last chance. I don't think we'll extend it anymore because otherwise there will be no conference talk. So Last chance if you want to speak in your language, either it's Portuguese, Spanish, or whatever, or English, actually, then please submit. We may need your help to add the subtitle there if you're speaking in another language but we have some AI tool that were given to you so you don't have to do the translation everything by yourself so yeah, that that that's it for now. So thank you.

Speaker 3

Thank you. Thank you so much.

26:01 7th Talk

Speaker 8

So my talk is about some work we've done recently, well, in our company, to make some improvements to Django migrations for Post RISC functions and triggers. So I work at Bohurst, where software platform which allows users to do searches over companies and sort of The infrastructure around that, so funders and get information on companies in the UK So I don't know if you lot have a lot of history of Django migrations. I actually remember a time when there wasn't a built-in migration system and we use like South and other stuff. But eventually we built migrations into Django. And some of the same issues now I feel

come up when we deal with Postgres functions, which is what we do a lot in Boheurus. So here we have an example of one of my PRs, and I just wanted a one-line change, but because of There's no built-in system to manage change management. We have the system of delete the old file, then have a superseded function error, and then create a new file with the new SQL for that function, which obviously isn't very good because now with our new system you can see exactly what lines change and it's very easy to do PRs So how did we get this migrations?

So and then obviously you run make migrations and it will do the actual hard bit So with Django migrations, the migration system is actually really good. So the way it works is has a project state and a model state and it looks, it runs each migration operation in turn. To modify the project state and the model state, and it looks at your actual models file and it compares the two, gives it to the migration auto detector, and that knows okay if the to turn from this project state to this project state I need to create an operation for add model create model

or delete model And we want to extend that to now just say move from this model state to this model state, create function. So quite simple to the whole system's hyper so change the some of the existing Django code to now use our new project state that understands what a function is and use that instead. There are some issues that come with this. There's you'd normally you'd want to put triggers and functions next to each other. So indexes we already have on models, but you don't have triggers But

you can't add actually add triggers to the meta. You have to I think most people add like a new meta file. It's it's been open for 14 years, I think 15 years now, so hopefully it'll be fixing. So yeah, so here I have to do an extended meta just to add the triggers. And it's quite hard to put the right functions in this right place, but we deal with that. And this is like hard-coded project state Which is not that nice because I want to use my new project state that understands what functions are. So I have to do a bit of an ugly Patch. So hopefully Django will

continue to work on more stuff so this can be a bit easier. But if this sort of interests you, some of the deep stuff we do in Django, we're hiring at Bohurst. So thank you very much.

Speaker 3

Thank you, Alien.

Speaker 5

Hello. So I'm going to talk to you about the Django Project. com search function that I rebuilt a few years ago and I'm trying to maintain until today.

30:07 8th Talk

Speaker 6

I'm Paulo Macchiore, I'm the CTO of 20Tab. I'm software engineer, Python developer, and Django contributor. This is a photo of me at Europeidon 2017, Rimini. I give my first talk about Fulter Search. It was new in Django, in Django 1. 10, and I found that very easily in the Django documentation and I tried to learn more about this subject because it was very interesting for me. And after the I presented this talk in various conferences and then I wrote an article about it and I g I received a lot of interesting feedback about that and I saw I started thinking to

I was implemented the search function in the Django project. com website and I found out that relies on external search engine so I decided to propose an implementation based on the Django itself And I organized a Django sprint in the EuroPython 2017. So with a group of people we made a proof of concept of this functionality, removing totally the search engine the external search engine. And then I worked to made a complete pull request and late the tier team helped me to complete this

pull request that we merged. And so in 2017 we started using Django itself to the Django search functionality. Since then I implemented various functionalities and sorry this is And last two years ago I opened this issue in the Django in GitHub to take track of new functionalities we can have we can implement it in the Django search functionality. And we upgraded Django 3. 2 to have web search highlighting functionality in it. We updated to

Postgres 12 to have more languages supported. One of the last we supported. a few minutes ago. It was Indonesian, so now you can read Django con weapon documentation Indonesia and search for it And another one was the web search functionalities from Postgres 12. So now you can Search for search like that using Boolean logic, removing what you don't want to search for. is only an example and this is pretty new a few minutes ago and

Well is we are trying to do a lot of work improving this functionality and I thank Marish and Carton to help us to deploy these new functionalities and to have feedbacks and we have new feature we want to implement there are people that are opening issue for example Adam opening this issue to promote and update also the foreign to be part of the search. And I'm here to ask you to try to use the Django search functionality. Don't complain with colleagues only, but open an issue if something didn't work.

try to help us to review pull requests that people are opening and help us if you can try to translate things and improve a lot this

Speaker 4

This functionality. And this is my contacts. If you are interested in the subject of full-text search and want to help improve this functionality also in the juggo project. com obsite I'm happy to be contacted with you. We can chat here or next day online.

Speaker 3

Thank you. Thank you so much

34:51 9th Talk

Speaker 4

thinking about Django SSR. What I mean in my firm we work really hard with View. js Who use Vue. js in together with Django? Yeah, of course. Probably you know Pains about this work. We my name is Maxim Danilev. I work with Django some time, and we start to work with Vue in 2021. and we use version Vue. js 2. 7.

Thank you for my team who helped me create this presentation and

Speaker 8

who test all my crazy ideas in own life. Okay, if we create some project stop if we create some project which use viewjs we have the this structure we have on front end view js after that view js ask server and server ask not just or server ask Django and not just ask Django with truth Django Rest framework from

Scrum. For example and we receive some answer to browser and on the client it should be all generated who use this

Speaker 4

mm structure in own work probably. Yeah. And after that we think What we should to do, this all works slowly. And after that we start to use cash. they start to use cache in browser, they start to use cache on the web server, image cache, they start to use async fetch on the not just the use API cache and we start to cache something on the Django in Django functions but it

Speaker 8

works slowly. What we can do? After that is start to create a new layer

Speaker 4

for our cache we can refactor components in Vue. js we can use magic settings in the web browser we can refactor our apis or refactor our serializer probably we start to use fast

Speaker 8

api in our project and

Speaker 4

Django we started to use defer only select related prefetch related for query sets We start to change settings in Node. js, but it works slowly. Who knows this problem? All works slowly. probably

Speaker 8

yeah what we can to do there and sometimes came to us somebody and say you should use

Speaker 4

SSR. Who knows this word? But I mean something others We can to use static side rendering, not server-side rendering. Okay, how it works with

Speaker 8

SSR? For first request browser ask our web server.

Speaker 4

Our web server goes to Node, Node ask Jangar REST API Django REST framework ask Django and after that answer and render it template came to the browser. It works faster for first request And after that on the browser comes hit

Speaker 8

radiation and we receive a complete app

Speaker 5

on our browser. It works. But something interesting here. On the other request, after the first request, we don't need node jails anymore. It's interesting. What we can do

Speaker 8

Probably we can't avoid can we avoid to use Node.

Speaker 6

js? No, we cannot avoid. But we can avoid to use Node. js for production. How? Probably we can use Django site rendering for a first request. But we have a team from Vue. js developers who create

Speaker 4

who create for us template. And idea was which

Speaker 3

is Maxim your time Maxim. Thank you so much.

Speaker 4

Last sentence please Node. js right now before production generate for Django templates and after that Django generate

Speaker 3

used these templates for first answer. We don't use Node. js anymore in our production for first request. That 's all that is Maxine