Lightning Talks II

This video features DjangoCon Europe Crew at DjangoCon Europe 2018 in Heidelberg, Germany.

Lightning Talks II
0:38:56
Published May 24, 2018
252 views

Summary

The lightning talks cover practical Django-adjacent projects and lessons: Peter Kierner explains C3VOC’s Python/GStreamer-based system for mixing, recording, streaming, and automating conference video; Arne Delat shows how a Django application manages cosmic-ray detector data used by schools; and Lacey Williams Henschel gives concrete advice for finding ideas, reading CFPs, writing proposals, and getting feedback. Leila Verhoeven describes building a blue Python-powered clock despite hardware and memory constraints, Lorenzo Peña presents a proof-of-concept combining django-tenants and django-polymorphic for multi-tenant user hierarchies, and Daniel Hepper demonstrates custom Django 2.0 path converters that can resolve URL parameters directly to model instances. The event’s running catering story provides comic transitions between speakers and ends with a pun about why the Australian stand has no queue for drinks.

Key takeaways

  • C3VOC’s Voctocore and Voctogui use Python, GStreamer, TCP commands, and Raspberry Pis to support flexible conference video production.
  • A Django-backed cosmic-ray project collects and analyzes billions of detector events while making data and educational tools available to schools.
  • Strong conference proposals start with a focused idea, follow the CFP’s exact requirements, and benefit from review by colleagues, mentors, or community members.
  • A small Python hardware project can succeed through iterative troubleshooting, including adapting to voltage differences and limited device memory.
  • Django-tenants can isolate tenant data with PostgreSQL schemas, while django-polymorphic can downcast inherited user models to their concrete types.
  • Custom Django path converters can validate URL values, convert them into Python objects, and support URL reversal with those objects.

Summarised automatically from the transcript.

Transcript

7,200 words · auto-generated Show

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

0:07

Speaker 1: As a last point today, we have lightning talks again and I think we were all looking forward to that. So I'll just hand it off to Russ again.

0:17

Speaker 2: Alright, it's time for lightning talks again. So we all remember from yesterday what the deal is. Five minutes, no more. But can be less if you want to, and we do like people who do less because it means we get more talks through. Uh there is a gong over here that will be attended to by my lovely assistant, uh, who will make sure that whoever is over here gets the message whenever their time is up. Uh there is a timer down here we're keeping keeping time to and wh while uh while we sit here and wait for people to get their AV set up, I get to regale you with delightful stories about uh The uh um the the individual yesterday who went was was dealing with the wasps after uh meeting the uh the head of the WASP uh con uh as a as an expert wasp uh observer. Uh Got involved with the organization of WASPCON and catering is a very big important

1:03

Speaker 2: part of any conference as we all know. But stories of this will progress Uh first up on stage we have Peter Kierner talking about recording lectures with Python and G streamer. Everyone please welcome

1:20

Speaker 3: I Peter, I would like to give you a small introduction to the soft and hardware we are using here in this venue and a lot of other conferences to record live streams of lectures and doing live streaming and recording. I can switch my slides. I'm from C3 Rock. We are the video operations center of the CCC. You can find a tons of information about video recording and streaming and production and distribution in our wiki and it's really not all that cleaned up but um it contains tons of information you can find me personally at uh under this nick on on twitter and um This is part of our pipe of our pipeline. It's only half of it. The upper half is concerned with capturing

2:06

Speaker 3: video signals from speaker notebooks and audio and video signals from the cameras around the lecture room All those signals are then fed into uh Vocdomix, that's these parts, and um it's a Python and GStreamer-based mixer solution. Um you can see from the schematic that it's basically split into two halves. One is VoctuCore, it's the like a headless server, and the other one is VoktuGUI. This is the streaming diagram, block diagram of VoctoCore. It basically acts as a network server accepting and providing video feeds on TCP ports. The mixing pipeline we implemented is very specific for lecture recording. You can transmit a nice pause animation and some elevator music during a break while continuing to recording

2:54

Speaker 3: the actual content so if you accidentally miss hitting the go live button you still have a useful recording. The mixing pipeline also can handle multiple audio feeds for live translations for example And it probably can be extended to do other nifty crazy stuff. From a code perspective, it basically looks like this. We are plugging together uh GStreamer pipelines in Python are strings and then giving them to GStreamer to parse them. GStreamer then implements builds a multimedia pipeline from it. It's like Lego for audio and video. You stick together the pieces you need. The UI looks like this. It connects to VoctuCore via TCP network, and when you press a button, it sends uh commands over there over a simple line-based protocol.

3:39

Speaker 3: So writing new GUIs or other interfaces is quite easy. You can literally mix video with Netcat and Telnet. It's really trivial to automate. Just one example is are these little guys, we have them here on our cameras. They are Raspberry Pis that connect to the VoctoCore and receive the line-based protocol and turn the light on the LED on whenever the camera is live. You can find all the code and a lot of the documentation in GitHub. And if you want to talk to us and have uh questions, please visit us. We are upstairs there. If you go upstairs, please be a little bit quiet. Oh they're winking. Um rink again. Way If you go upstairs please be quiet, but you can al uh always talk to us and we're really open and welcome to explain to you

4:26

Speaker 3: uh what we're doing. And because we have a really nice setup here, I have some pictures, this is the main camera that's right there in the middle of you. We have a second camera above there. And we also have like this is uh a really nice view from our mixing console upstairs. So thank you very much. And if you have any questions, please approach us and we will explain you how to set up your own video recording for your own conferences Thank you very much.

5:00

Speaker 2: Thank you very much, Peter. Uh while we get our next speaker set up. So he gets uh this this guy gets the job uh to organize the conference catering and uh so he goes out to uh uh uh like essentially a a conference conference to go and for get f where all the vendors turn up and show their wares and talk about what they what they can do and what they can provide for your conference. And then this uh this place has got tents set up and every every vendor has their own tent where they can you know demonstrate how they can serve food and how much food they can serve and and what have you. And so he turns up and he sort of walks into the first tent. Uh and the first tent is uh selling essentially German-themed food. There's like there's a a selection of uh uh of Wurst and sauerkraut and homemade mustards and uh There's some decent cues, people drunk lining up to get in there. And then there's some really, really long cues because they're also serving beer in the tent, and the you know the longest cue

5:46

Speaker 2: is to get to the beer. Um so uh this guy stands there, he tries the food. He says, Yeah, this is all very good food, but you know the cues are a bit of a problem, particularly the long lines for the drinks. Um people are willing to wait for you know food for a little bit, but you know you really don't want to get 'em waiting too long for a drink. Um So okay, maybe I'll I'll I'll try again. I'll I'll try and try another location, uh another one of the tents and see where maybe where that's going to be better suited to uh uh to our needs So he goes on to the uh to the next tent. The next tent is an uh American barbecue themed tent. They've got uh all sorts of different barbecues, a southern barbecue, a Texas barbecue. uh Kansas barbecue that are all very don't ever get into a barbecue discussion with an American. They get very, very touchy about barbecue. Um and so there's all this barbecue and there's fresh coleslaw.

6:32

Speaker 2: Uh and there's no some decent cues again, people lining up and getting their food, getting their barbecue. But then there's then there's uh some freshly squeezed lemonade is the sort of the drink that they're offering there. Again, really long cues for this fresh squeeze lemonade, but because it's really good, but also it just takes a while to produce to get a good glass of lemonade. So there's these long cues and The guy's in there and he tries it out and the food's really good. Barbecue's really good. Good selection of barbecue and the the coleslaw that goes with it's really good as well. And uh still going, all right. Uh the Uh but and and the again the lemonade is refreshing and it's and it's tasty, but uh again, long, really long lines getting to get this get yourself a drink. So okay, this is probably probably not gonna be the one for us. Are we nope?

7:17

Speaker 2: Alright, so he tries the next tent. This is I'm moving through far too many of my tents here. I'm gonna have to invent some new tents. He gets through the next tent, and the next tent is uh a different type of barbecue, this is Brazilian barbecue So Brazilian barbecue, if you don't know, is basically all about meat. Brazilians really do like their meat. So he goes in and he says, okay, yes, here we go. Some. beautiful meat on the on on the on the uh the great big skewers. If you've ever been to uh Turoshia, it's a fantastic way of having having sort of Brazilian barbecue. And the the vendors there are slicing big big pieces of meat off of the off of the uh the skewers and and serving to to each of the individual um uh uh uh patrons as they turn up. Uh being Brazilian though there is no salad that goes with it, it's just just the meat. And uh they've also got uh

8:03

Speaker 2: still waiting for yeah, okay, we're still going. Um we he's going through the uh uh Uh they've they've got uh uh a caprinha station there 'cause the Brazilians they do do make a very good caprinha made out of you know really good imported cachaça Delicious, but again, reasonable cues for the food. They can get the food out going out relatively quickly. But the uh uh the the drink station it takes a while to mix a good c uh caprina, so uh there's a there's really really long lines for the uh uh for the caprinias. Um and so he moves on this uh to the next tent. Next tent is uh Italian themed tent. Um Have we got an ETA at all? I'm whether we're kicking EHR.

8:49

Speaker 2: Um yeah, so it's an Italian themed tent. Uh and it so it goes in there and it's as you predict the sort of the pastas and uh uh and meals like that with some uh some nice nice salads on the side as well. This was not the agreed pattern. This is gonna turn into a five-minute joke in between all the other da all the others. Alright, so we're getting another laptop lineup. So it's the Italian themed booth Uh we have the Italian the Italian themed meal. We've got the pastas and the pastas are all there and there's some salads. Uh and of course it's Italian, so we've got some good red wine there and they've got the red wine coming out. But again, decent cues for the food.

9:36

Speaker 2: People are moving the food through relatively quickly, but then the lines for the for the for the for the drinks for this red wines. Really, really long lines as everybody gets their uh uh gets the gets the uh gets their drinks This is a possibility. I might get a breather here. We're getting we're getting close. Flashes. Oh, we're waiting for flashes. Okay Um sorry okay the the the the uh the guy organizing this conference is starting to get a little bit concerned. It seems to be a recurring theme here. We sort of go into all these boo booths, really, really good creative food vendors producing really really tasty food Um but there's long lines at every drink station that they turn up to. And that's full screen either.

10:17

Speaker 4: And S D R G L

10:20

Speaker 2: and That's the line up there. Yeah, there we go. Alright. But he can tell that uh that he's gonna have to keep looking. Um I'm gonna have to keep looking as well. um to uh to to see if he can find the vendor that's going to be right for him. And are we uh get downloaded first? We've got to download the whole okay. Um

10:51

Speaker 4: And then it would work.

10:54

Speaker 2: There you go. There we go. Alright. So The search will continue after the break. Next we have right up here on stage now we have Arne Delat uh with cosmic ray research with data analysis via Django and some astroparticle physics. Take it away, Arni.

11:16

Speaker 5: Good afternoon. I now work at Localo doing web development. My previous job was doing astroparticle physics. Uh astroparticle physics at NICEF in Amsterdam. There I analyzed stuff with supernova. So this is an image of a supernova explosion where a star explodes. The shell of particles being ejected by the supernova accelerates particles which are just out there in space. It picks them up and accelerates them and using big magnets it keeps them until they're fast enough and then injects them all throughout space. Some of those particles moving at almost the speed of light hit the Earth. Uh then this happens.

12:02

Speaker 5: There's a particle at the top and it hits another particle in our atmosphere and there's so much energy that they create more particles and those particles have enough energy to collide again and create more particles until you have on the ground maybe between one and several billion particles. Uh those are just electrons, muons, which are the slightly heavier version of electrons. Um and there's yeah at High Spark we uh detect those particles. So in the top right you see a scintillator which glows a bit if those particles go through it. We wrap those in light tight plastic and then we put them in those keyboxes. and there are photomultipliers connected

12:47

Speaker 5: which see the scintillator glow and they convert that to a strong elektrisch signal. Then you have the little box on the lower right left and it converts the elektrische signals into bits and bytes and it continuously reads out the signal every two and a half nanoseconds so you get this really sharp signal. Um and then we put several of those detectors very close together so you can see if multiple of them are hit then you have are dealing with one of those air showers. If only one sees something then it's probably some background radiation. Not interesting. So this is how the network looks like you have huge things in space which shoot out these cosmic rays Uh these cosmic rays interact uh in our atmosphere

13:34

Speaker 5: and we have several detector stations uh and they detect These events, all the data is sent to the NICAF in Amsterdam where we do a bunch of data analysis, and there's this nice Django application which does all the bookkeeping and manages all this. So there are about a hundred of these detection stations. Most of them are at high schools. So it's an outreach project. High school students build these detectors, they put them on the roof of their schools. They can then work with the data from their station, from all the other stations, and do nice experiments, see what they can learn about relativity, quantum physics, and other interesting stuff. This is an example of an event at the Science Park in Amsterdam

14:21

Speaker 5: where there are several stations very close together. The color indicates the arrival time, so more blue is earlier, redder is later. So you have this one particle coming from outer space, it creates all these new particles and they all go at the speed of light. So you basically if you Take a snapshot, it's all these particles in the flat plane. So they also hit the ground in that plane in that plane. So first they hit on the right and then a bit later there and there and there and there. So using that timing difference you can get a sense of the direction of this air shower and using the number of particles which is indicated by the size of the blobs. You can guess where the center of the core was and then you know something about the energy of the air shower, you know something about the energy of the cosmic ray and you might guess where it came from

15:08

Speaker 5: with the direction. It's all very interesting. Um so we have a lot of teaching material and tools for these high school students to work with this data. A lot of documentation, all the code is open source, so the code running on the detection stations, the Django that's uh Managing all the uh data coming in. This project has been running since 2004. There's about six billion events uh that have been detected which is about six terabytes of data which is then reduced uh reconstructed and all that data is made available via nice apis and we provide a nice JavaScript tools to do stuff with it and Python framework to also do analysis with it. It's all uh very nice.

15:54

Speaker 5: Uh And yeah, this used to be a movie, but now it's a PDF because it was on my laptop. But maybe I can show it quickly and but yeah. Oh, where's the slash there?

16:29

Speaker 2: Alrighty, thank you very much, Anne. Okay, so whilst our next speaker gets set up, the search continues for the purpose perfect conference food. And so having been to the German tent and the uh the Italian tent and the Brazilian tent uh the and the US barbecue tent, uh the uh the guy walks on to the next tent. The next tent is uh a Mexican tent. And so they've got a little uh essentially little taco truck set up in there So they've got the people behind the counter furiously making tacos for everybody and they're beautiful. I have fish tacos and chicken tacos and beef tacos, and they're all fantastic. Uh and then um I've got a little margarita stand on the side, so they're making margaritas for everybody to drink while they're at it. And are we good to go Yeah, so again, I think we've got the long lines for the margaritas, but uh the rest of the food goes through well. But the long lines are a problem. Need to look somewhere else.

17:14

Speaker 2: Our next speaker is Lacey Williams Henshill talking about how to propose a talk. We went like a welcome.

17:26

Speaker 6: I have to figure out where to stand because I'm really short But I don't have a clicker either. So yeah, um I wanna talk to you about how to propose a conference talk because I work on conferences and I speak at conferences and so I've I've done this a few times. I need to stay over here though so the mic catches me So the first thing that you need to do a conference talk, oh, there's the timer over there, that's nice, is an idea, right? And so where do you get ideas? So you can think about what have you learned recently. My personal opinion is that the most qualified person to speak on a given topic is the person who was most recently completely perplexed by that topic. Because you know what you had to do to get over that hump to figure out how to understand that. Sometimes you have really strong opinions about something, like you think that testing should be done a very particular way, or you think that code should be organized in this very, very specific way.

18:12

Speaker 6: You can share those very strong opinions with a group Sometimes something that that really confused you now makes sense to you. And so again, this is related to one, but it's it's also its own separate thing. So there's learning a new thing. But then there's taking a thing that you you kind of understood before, and then finally you really, really, really understand it. For example, Katie's talk about the ORM. Then you need to think about your talk a little bit. So you want to think about is your how broad is your your topic? So like like I said, for example, testing You really can't just give a talk about testing in about half an hour, right? Like a general topic, um a general conference talk is about 25 to 30 minutes. So think about can I sum up this topic in two minutes to someone who doesn't know very much about it? Like hit my high points.

18:58

Speaker 6: Get my arc, and then you know, okay, I've got a decent idea. Once you have an idea and you're thinking, I am ready, I want to propose this talk, You want to find the CFP. CFP stands for Call for Proposals. And the first thing that you want to do is read that CFP carefully. Not all CFPs are created equal. They all have their own special requirements. They also all have deadlines and it is very unfortunate as an organizer whenever someone emails you and they said, Oh, I'm so sorry, I just missed the deadline, I had it wrong in my calendar. You don't want that to be you, so you want to pay very close attention to the deadline and also attention to the time zone that the deadline is in Finally, you want to make sure that you know what the anonymity requirements are, right? So a lot of CFPs require an anonymous submission.

19:45

Speaker 6: So you might be tempted in your talk to talk about your credentials, and there's certainly place for you to do that, but you want to make sure that if this is an anonymous review process, that you're not putting identifiable information in the body of your proposal. Finally, or not finally, the next step is you actually have to write the CFP, right? You have to write your proposal, get it ready to submit. In general, you're going to want a short abstract, which it gets printed in the program or put on the website that's about 300 characters. Then you'll want a longer description that gives the organizers a chance to see that that you're you're prepared to talk on this topic, that you you know what you're doing. Sometimes you want an outline. Some conferences even want you to have an outline that includes the time. So you, you know, you're gonna spend one minute on the introduction and you're gonna spend three minutes talking about this.

20:32

Speaker 6: Those are kind of annoying, but you have to do it anyway. So make sure, again, read the CFP closely and make sure that you're following their um their prescription. Then you want to write your bio. And this is the thing that really trips people up. It is really hard to write about yourself, like it sucks a lot. So there are some tools online that can help you. I will tweet those later on, and you'll notice that my Twitter and a couple of other Twitter accounts are at the bottom there. So yeah, you'll want to prepare some kind of statement about yourself that again gets put on the website, maybe printed in the program to let people know who you are. Then you'll want to edit your CFP. So this is before you submit. Don't just type it all into the window and then hit submit. You want to run this by somebody. So you can run this by your friends, you can run this by colleagues at the place where you work or people that you've worked with before.

21:19

Speaker 6: A lot of times conferences will have speaker mentors, so you can go to the website or email the conference and see if that's something that you can take advantage of. You can reach out on Twitter and say, hey, I want to submit a talk on this topic. Will someone review this? And people will say yes. They will just say, hey, send me the link and they will give you feedback. Also, Slacks that you're in are a really great opportunity Then you actually hit submit, and this is a really really proud moment, right? But you might have some concerns about speaking at conferences. So for example, you might wonder if you know enough to present on a topic, and the answer is yes that you do You also might be worried about how much it costs. A lot of conferences have financial aid. You might be concerned about your work and whether they'll support you. You should just ask. My experience is that a lot of bosses, if you're if you're speaking, will say yes. And you might wonder if you'll get rejected.

22:04

Speaker 6: So I if if you have spoken at a conference ever, raise your hand. If you have never been rejected from a conference, keep your hand up. Or like I guess oh I'm sorry, I I did that wrong because I'm running out of time. But basically there are two CFPs that are open right now. I have two seconds left. Take a picture of this slide, DjangoCon AU and DjangoCon.

22:28

Speaker 2: Thank you very much, Lacey. Okay, so uh uh we've uh Mexican didn't work out, so uh our um Next speaker next vendor that he tries out is the Spanish, uh Spanish vendor. And uh inside the Spanish tent they've uh they've got a little tapas bar set up. So you know pick up your own little pieces of tapas from the from the from the selections that are there. Uh and there's a uh uh you know really wide selection of tapas, quite impressive. Not not too bad cues going on with uh with what's there Uh and the uh the drinks is they they're serving sangria, which is you know lovely, but again, really long cues on the sangria. So uh this this is gonna be a problem. It seems to be a recurring theme. It's like the food food doesn't seem to be an issue. People can get the food out relatively quickly. Um but the uh but the uh but the drinks lines are becoming a bit of a concern.

23:14

Speaker 2: Are we good to go? Yes, we're good to go. Alright, so our next speaker is uh uh I made a clock in Python, Leila Verhogen Take it away.

23:22

Speaker 7: Hello. Well hello, my name is Leila and I will talk to you about making a clock in Python. So a few months ago my clock was broken, just like this one. And I wanted a new one. With a few basic requirement requirements. it had to be blue and the time had to be visible when it was dark. After searching a lot and only finding red and green uh and or green ones, I finally decided to make it myself. To make this clock I used an M0 Twin Cat R T C module and a blue squad seven segment display on its driver. I also used a breadboard and a lot of wires.

24:11

Speaker 7: As you can see, I used a medium and a small whiteboard. On the top it's a secret page, it's the secret without component. And on the bottom, the thing in the middle, it's uh three from three volt to five volt one way logic converter because the data sheet say the OTC and display drivers needed 5 volts and the twinket outputs 3. 3 volt But I should have a two-way logic converter to this to this to work and I didn't have one. In the end, it turns out both the RTC and the display driver

24:57

Speaker 7: work fine with a three point three vote signal, so I got with of the logic converter altogether. At this point I also decided to use a single radium breadboard so I had to make a new circuit Both Ltc and DisplayDriver come with their own Python module, but both modules don't fit in memory at once. So I had to write my own dead time management library to under the RTC module to and save some memory As you can see on this photo, the clock finally works after four days of making circuits and two hours of writing code. And it was very, very satisfying to see it work

25:43

Speaker 7: Well, after my success with the small clock I now want a bigger one. A slightly different one. I decided to make one with pizza boxes and NeoPixels. If you don't know, Neopixels are bright LGB lead. Right now this project is still work in progress because I haven't time to finish yet but I think I will work on it after this conf. If I talk to you about this clock today it's because I know that sometimes We want to give up, but I also know that if we preserve we can climb climb mountains and even more Thank you.

26:37

Speaker 2: Thank you very much. Um okay, can yep, let me take a station then. Here we go. Yep, all right, there we go. We have another speaker. Um so The search continues. Uh we've tried Mexican, we've tried the uh the the uh Spanish, we've tried the American barbecue, we've tried Brazilian barbecue, we've tr The German All got the same basic problem going on here. Um so we start next okay, we're going to the there's an Indian tent in the Indian uh uh uh subcontinent India that all sorts of curries, so it's uh you know large, large sort of bamarie uh trays filled with all sorts of aromatic curries and you know add a bonus some of these a lot of these are vegetarian, they're all still really, really great food. Uh and you know big one big b bowl of rice to serve out as well. So Relatively fast moving cues getting to all of the uh all of all of the curries that are there. Uh but then there's the uh uh the drink station. They

27:22

Speaker 2: 're making uh mango lassies, uh yogurt, yogurt drinks Uh and again, really long cues on the on the Mango Lassie for some reason. Uh so okay, so this probably isn't going to be the one we've we've got a problem with the long cues again. Um so the search continues. Uh our next speaker is Lorenzo Peña uh talking about multi-tenant polymorphic users

27:42

Speaker 8: Okay. Hi everyone. My name is Lorenzo Peña. I am Laurincos at Twitter, GitHub, Facebook, Gmail, and pretty much everywhere. I come from Holging, Cuba, and it's a great privilege to be here today. Big thanks to the YangoCon crew. This is my first YangoCon ever, my first time in Europe, my second time outside of Cuba. My first time publicly speaking in English and my ninth year in the exciting world of Yango. I somehow expect that nine to compensate for all the former ones and twos The code name for this lining talk is MTPU, which stands for multi-tenant polymorphic users, which in turn is the fanciest name I could find to summarize the otherwise longer Quick recipe for creating a simple software as a service with user hierarchies that gratefully downcast based on the current tenant. So big dicks disclaimer, this is just a recipe.

28:29

Speaker 8: I didn't create any of the ingredients myself. This is Only intended as a fun experiment. This is no silver bullet for anything. Consult your doctor before attempting this on production environment. Ready? Okay, here we go. Suppose we own shiny domain. com and we want to build a shiny software as a service using a single Django project. At www. shinidomain. com we're going to have the corporate side where our customers will acquire private space at whatever name they choose, shinidomain. com So far so good. Now come the users. For most practical cases, we might not want to store the same information for our possible user types in a project like this. Think of it at the W site. We're going to have our corporate users who should be dealing with tenant management, customer service, all sort of super cool enterprise cover operations and hopefully payment processing And at any subdomain chinidomain.

29:15

Speaker 8: com we're going to have the user structure that makes sense at the application level we are offering as a service and isolated users. It could be a single user type or it could actually be a hierarchy of user types. Yango Contrib Alth comes with default user model and in order to store all relevant information depending on the user type, we could fall back to using profile models with one-to-one relationship to the user. as is still suggested somewhere in the Yango Docs. However, that would take all the fun out of this experiment. Besides, there is another implicit way of creating one-to-one field. So we are going to use a custom user model actually a custom concrete base user model that other user models will inherit to create a hierarchy so cooking time Here are our selected ingredients for the MTPU recipe. For solving the multi-tenancy problem in a single Yango project, we're going to use Yango tenants.

30:02

Speaker 8: It relies on Postgres schemas to isolate tenant tables within a single database. And as other packages that rely on post-grid schemas, it creates a new schema for every new tenant while keeping all shared tables in default public schema. For more ingredients like this Can be found at the fresh market, aka Django Packages. com under the multi-tenancy grid. And for handling not too complex model hierarchies, we're going to use Django Django Polymorphic. With this package, if we define models that That use concrete inertance, we can query the parent models and get the downcasted instances. So if we have places, restaurants and bistros where place is the base class for restaurants and bistros We can query places and get not just places instances as vanilla Yango returns, but the actual type of existing instances. This comes at the cost of some extra joints, some drag in performance, and a little bit of dark magic.

30:49

Speaker 8: But shouldn't be a great problem if the hierarchy is not super complicated model tree. Again, more ingredients like this can be found on the model inheritance grid of YangoPackages. com. So how these ingredients work together first Forgetting polymorphic users, we just need to define a custom user model and inherit polymorphic model. We might want to inherit also abstract base user to incorporate common user functionality. Just make sure polymorphic model is the first one in the list so that polymorphic behavior actually works We must also define a manager that needed its polymorphic manager and uses default manager for the base user model. For Yango tenants to work properly, there are some preliminary steps we need to take. like creating the tenant and domain models. However, we are going to spare the details here for the sake of time. The only thing we are going to cover here is tenant and shared application. They're not tenants As the concept of shared apps and tenant apps. With this the regular settings for install apps become just another union of the former

31:35

Speaker 8: models in shared apps will live in the default schema while models in models in tenant apps will live in every other schema that is created for a tenant. If the same app is provided both in shared and tenant apps Its models will live in all schemas, but notice in the context of any tenant tables in tenant schemas will take precedence over those in the public schema. There is more to talk about this. We can skip the correct details for now. So all you we just have to do is know where to place everything and since we don't have time anymore and this we could be in the side inside the cage I'm just going to leave here uh proof of concept if you want to see it in action. Thank you very much.

32:21

Speaker 2: Thank you very much. All right, we have our one last lightning speaker to talk to talk today while they get set up. Our uh intrepid wasp expert is starting to get a little bit desperate. He he is really trying to look for a The perfect cuisine that is going to work and be able to be served quickly to a you know the large wasp enthusiast audience. And uh he finally comes across the Australian tent. The Australian tent is uh sort of this weird Asian fusion thing, so it's like uh kangaroo carpaccio or kangaroo um and there's there's emu satay. and uh all sorts of weird combinations of uh of Australian foo, Australian uh uh native animals that are done in a sort of a vaguely Asian sort of style, which is And it's sort of unusual. It's uh but he you know there's still there's still people here, so obviously it can't be bad. So he lines up and he uh uh

33:07

Speaker 2: gets in the queue and this food's really, really good. It's been expertly prepared and it comes out quickly. Um And uh so okay, so and then he goes over and looks for the drink situation. And uh there's a there's a uh they 're serving a fruit punch, there's a native Australian fruit punch, which okay sound sounds good, but there's n there's no line. There's no no line at all This is this is weird, so I s I have to work out what's going on here. Um our next speaker is uh uh the is Daniel Hepper talking about the hidden powers of custom Django path converters. Thank you very much.

33:44

Speaker 3: Hi, I'm Daniel and I want to uh show you a somewhat obscure feature I

33:49

Speaker 8: that's new in Django two point zero So who read the release notes? What's new in Django two point oh? Yay, no more regular expressions in URLs. We have a simplified URL routing syntax instead of using URL with a path with a regular expression in it, you use uh the path method with uh a capturing and to capture an URL argument you use uh angle brackets and uh After the column that's the name of the argument and before the column that's a so-called path converter, which you can define. So path converter converts. So it in this case it converts the argument into an integer so your view will actually get an integer and not uh a string as it used to be. So there are a couple of built-in path converters.

34:35

Speaker 8: Uh under the hood they still use a regular expression so string, integers, slug, path, and also uh UUID. But now you might say, wait a minute, that's not really feature equivalent. The regular expression that accepts exactly four digits and an integer can be like any number of digits, basically. So that's where custom path converters come into play. It's a plain class that has uh again

35:01

Speaker 3: a regular expression. So if you hate regular expression, kind of bad news. Um And it has a two-Python method, which uh handles the converting from the URL to the uh Python object, and it has a two

35:14

Speaker 8: URL method which handles the reversal. So now we for our four gig uh URL pattern that's um the you uh the custom path converter. To use it you have to register it uh and give it a name and the name is what you then use in URL. So far so good. That's all in the documentation. But this line caught my eye. what happens when that value error gets raised. You might expect that you get a server error or something like that, but actually the conversion is part of the matching.

35:50

Speaker 3: So uh if a value error gets raised the path just doesn't match. So how can we use it? Let's say we have a URL um which gets an ID and then you have an a view which gets an object or returns a 4 by 404 and uh you also have a URL um tag in a template that does the rehearsal.

36:09

Speaker 8: Now you can write a custom converter class which uh fetches the object in the toPython um method and raises

36:17

Speaker 3: a value error if the object doesn't exist. and

36:20

Speaker 8: the two

36:20

Speaker 3: URL method just takes uh returns the ID of the object. Uh you register that converter and give it a name. In this case I was not very creative so it's a question converter And now your

36:32

Speaker 8: view uh receives a question object and you can also just pass a question object to your uh r URL reversal.

36:40

Speaker 3: Now you don't want to write a converter for each model obviously, so you can generalize that and um I wrote a register model converter method which dynamically builds um a model converter class. Which you can use like this. And by default it just uses the name of the model as the name of the converter. Um Then I came up with a couple of other useful features like passing uh an optional name and using a different field for lookup and different using a different base class. If your

37:11

Speaker 5: for example your primary key is a UE ID, you can also pass a query set.

37:16

Speaker 3: That's where the advertising part starts. I packaged that in a um Python package which you can just install with pip install Django model path converter. And then you just do register model

37:27

Speaker 6: converter. with your model class. And then you have views in your uh

37:33

Speaker 8: models in your view. Um here

37:37

Speaker 3: are the links to the PyPy and GitHub um and also my Twitter and my email if you want to tell me why that's a bad idea. Thank you

37:53

Speaker 2: very much. The Lightning Talks for today. Thank you very much to all the Lightning Talk speakers. Thank you very much to our delightful uh gonging person who didn't have a great deal of need to gong because everybody was under time. That's wonderful. Um one last issue that we have to work out though is why why was the Australian queue able to why were they able to get through the drinks so quickly? And so the uh the guy who's uh organizing WASPCON uh comes up to the uh the goes goes to find the the the the manager of the the Australian tents says, so what's the story here? What's going on? Like everyone else, I've been to all these other tents, I've been to Mexican tents, I've been to American tents, I've been to Brazilian tents. They've all got, you know, good rates of throughput for the food, but they've they've got huge, huge lines for the drinks. And I come in here and you're serving this delicious punch, which is, you know, it's it's fantastic, but there's there's no cue. So what's the story? And the uh so the Australian manager turns to turns to the guy and looks him straight in the eye and says, why would there be a punchline?

Questions this talk answers

How can I record and livestream conference lectures with Python and GStreamer?

The C3VOC setup uses a Python-and-GStreamer mixer split into a headless VoctuCore server and a VoctuGUI interface. It accepts video and audio feeds over the network, supports breaks, multiple audio feeds such as translations, and can be controlled through a simple line-based protocol.

Discussed at 1:20

How does Django help analyze cosmic-ray detector data?

The HiSPARC project sends data from roughly 100 school-based detector stations to NIKHEF in Amsterdam, where a Django application handles bookkeeping and manages the incoming data. The project exposes reconstructed data through APIs and provides JavaScript and Python tools for analysis.

Discussed at 13:34

How do I come up with and submit a conference talk proposal?

Start with something you recently learned, a strong technical opinion, or a topic that only recently became clear to you, then narrow it to a manageable talk. Read the CFP carefully for its format, deadline, time zone, and anonymity rules; prepare the abstract, description, outline, and bio; have others review it; and then submit it.

Discussed at 17:26

How can I build a digital clock in Python with a seven-segment display?

Leila built one with a Trinket M0, an RTC module, a blue seven-segment display and driver, a breadboard, and wiring. Because the RTC and display modules did not fit in memory together, she wrote her own date-time management library, and both components ultimately worked with the board’s 3.3-volt signal without a logic converter.

Discussed at 23:51

How do I build a multi-tenant SaaS with polymorphic users in Django?

Use a tenant package such as django-tenants to isolate each tenant in a PostgreSQL schema, and Django Polymorphic with a custom concrete user model to represent user hierarchies and return downcast child instances. Shared applications live in the public schema, while tenant applications are replicated into each tenant schema; the approach is presented as a proof-of-concept rather than a production-ready solution.

Discussed at 30:02

How do custom Django path converters work in Django 2.0?

A custom converter is a class with a regular expression, a to_python method for converting the URL value, and a to_url method for URL reversal; you register it and use its name in a path pattern. If to_python raises ValueError, Django treats the route as non-matching, which can be used to fetch an object and pass it directly to the view while returning a 404 when it does not exist.

Discussed at 34:49

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 DjangoCon Europe Crew

More videos from DjangoCon Europe