Django is without a doubt one of the most used web frameworks for Python. Lacey Williams Henschel is a Django consultant and has joined me to talk about Django, the Django community, learning Django, software testing, so much more.

Transcript for episode 103 of the Test & Code Podcast

This transcript starts as an auto generated transcript.
PRs welcome if you want to help fix any errors.

00:00:00 Django is without a doubt one of the most used web frameworks for Python. Lacey Williams Henshall. He is a Django consultant and has joined me to talk about Django, the Django community and so much more. Thank you, Regan, for sponsoring this episode. Code, top notch Error Crash and Performance Monitoring. That’s easy to use. More about them later.

00:00:33 Welcome to Test and Code, a podcast about software development, software testing and Python.

00:00:44 I am excited today on Test and Code have Lacey Williams Henshall. So welcome to the show.

00:00:50 Hi. Thanks for having me.

00:00:51 We met at PyCon a long time ago, and I know that you do Django. That’s about all I know about you.

00:00:57 Yeah.

00:00:57 So tell me who you are.

00:00:59 So I’ve been doing Django now for five or seven years. It’s kind of hard to keep track. I’ve been doing Django full time for about two or three years, and right now I work for a consultancy called Revsis. Revsis is based out of Kansas, but I’m located in Oregon, in Portland, Oregon. And then yeah, I’ve been pretty involved in the Djangokan US conference for the past several years. I’ve organized some Django Girls workshops in the past, so I tend to be relatively well involved in the Django community as a whole.

00:01:30 Cool. Having two daughters. I’m excited about the whole Django Girls angle. I was going to ask you mostly about Django, but what is Django Girls?

00:01:38 Yeah. So Django Girls is an organization that helps people put on workshops in their own communities to teach primarily women how to write a website in Django. Basically, the workshops last about a day and a half, so they kind of learn how to do everything. They learn some basic HTML, some basic Python, and then enough Django to sort of get a website up and running and they even deploy a website. I think that these days they deploy on Python anywhere, but I’m not sure it’s been a while since I coached in a workshop where I organized one. But I know that Portland had one just about a week and a half ago, I think as part of Pycascades, which was here just last weekend. And then they also have their tutorial all online for free. And I think that it’s a really excellent tutorial for someone who is brand new to Django and also brand new to coding, because it just goes right into the basics of some other tutorials that I can think of to like, you just never know where someone’s coming from. And so if you’re someone who’s coming from really not having any technical experience, then the Django Girls tutorial is really nice because it starts you from that very basic level and then builds up from there.

00:02:49 Okay. How involved are you with the Django Con?

00:02:52 I’ve been pretty involved for the past five years or so. I’ve been the chair before or the co chair before. I’ve also been the diversity and inclusion and financial aid chairs last year, I didn’t have a formal role in organizing the conference, but I was still kind of available behind the scenes to answer questions and contribute to the website, contribute changes to some of the communications that we send out. It’s a really great team, though. I really enjoy being part of it. I’m really proud of where the conference has kind of gone over the last several years.

00:03:24 Do you know where it’s at this year in San Diego?

00:03:26 I think that was recently announced, and we’re working on putting the website for 2020 together as we speak.

00:03:32 Okay, cool.

00:03:33 So this will be our third year in San Diego, and I think in 2021 they’ll move it to somewhere else.

00:03:38 You brought up Pi Cascades, and I’m mostly familiar with So Pikascades this last weekend. That was the first time I’d been to that event. And it’s two days. Single track. Python is larger, much larger. Multi track, and I guess it’s still like two or three days, but multitrack makes it a lot bigger. What’s Djangokon like? Is it a single track thing or is it multi tracks?

00:04:01 Djangoon is two track, so it’s three days, and most of the time, all three days are single track. Last year, they experimented with having the third day be single track instead of double track. And so that third day was supposed to be. Are you familiar with the Django Under the Hood conference? No, it hasn’t happened in a few years. I don’t think it’s happening anymore, but it ran for a few years in Europe, and the idea behind it was a conference for really deep dive into Django content, so especially deep dives into the Django code base. I never got to attend, but it was really well received, and it was something that people felt like was maybe missing from some of the Django cons. Jango Con US, Jango Con Europe, Django Con Australia, where these really slightly longer talks that kind of went into a greater detail about some of the Django code. And so that was supposed to be the idea behind the third day last year.

00:04:59 It was the deep dive day. It was a day of longer talks that were more about Django internals or more complex topics in Django. I didn’t get to attend Django Con last year, so I didn’t get to see it in person, but from what I understand, it was really well received. I’m not sure if they’ll be repeating it again this year, but I think it would be exciting if they did.

00:05:20 It’s kind of a neat idea to reserve some of the longer talks for some deep dive detail stuff.

00:05:26 Yeah. And it’s just a different kind of talk, too. It’s a fun kind of talk to recruit for.

00:05:32 Personally, I would find giving that kind of talk to be sort of intimidating. Right. To take up this longer slot and to really go deep into a particular topic, I kind of like to do introductory styles of talks. I find that really comfortable, but I think that seeing talks like that would be really fun too. And I think that even beginners can get a lot from a talk like that, even if you’re not quite to the point in your Django experience where you’re really fully understanding what you’re hearing. Still, being exposed to those ideas, I think, can go a long way toward deepening your understanding as time goes on.

00:06:08 This episode of Test and Code is sponsored by Ray Gun. Save time with Ray Gun. Crash Reporting detect, diagnose and destroy errors that are affecting your customers. With smart Python error monitoring software from Regan, you can be alerted to issues affecting your users the second they happen have complete visibility of your app or website, so you discover and fix errors and perform issues before your customers experience them. Regan takes you to the exact line of code where the errors occurred and tells you how many times it’s happened and exactly who has been affected by it. All errors are reported to your Regan dashboard automatically, along with full diagnostic details on how to solve them.

00:06:46 Regan has also fine tuned the filtering notification control so you can focus on fixing important issues and problems affecting most users and not be bombarded with redundant notifications. It takes just minutes to set up. Try it yourself by going to That’s Thanks, Raygan for sponsoring this episode.

00:07:10 One of the questions I had is why do we need DjangoCon if we already have Python?

00:07:14 Python is the more general conference, right? Like Python is going to have a lot of talks that are about Python, but not necessarily Django or that are about web frameworks other than Django, like Flask or things like that. And I thought that those talks don’t have a place at Django Con. We have talks that are not specifically about Django at Django Con as well, but it is a more specific kind of community, right? So you get four or 500 people together who are all interested in Django, and then you end up having all these hallway conversations about Django or DRFs or workshops or problems that you’re having that are specific to Django, and you have all these people that can help you with those problems or talk to you about these topics. Python is thousands of people, right? It’s like two to 3000 people these days. So just in terms of the hallway track alone, finding specifically the Django people, if you have Django questions is a little bit more of a challenge. And then Python too. They usually have a few Django talks, which is great, but it’s really great to have a conference where the bulk of the talks are going to have some content that like I as a web developer who works in Django every day, I can have those takeaways that. I go right back to my desk and I can implement this thing that I learned.

00:08:27 Yeah.

00:08:27 But also I’m just really pro there being more regional conferences and more subtopical conferences.

00:08:34 There’s Pi Data, which I think is like Python from a data science perspective. There’s another Python conference that’s like subtropical, kind of like that. But I can’t think of it right now, but I feel like there’s another one. But then there’s all these regional conferences, too. Not everyone can go to Python. Pycon sells out. I think it’s really nice to just have more conferences anyway, to sort of spread around the opportunity for people to have the chance to go to a conference at all.

00:09:01 One of the things I’ve noticed, I’ve gone through a couple I actually have not actually finished the tutorials. I’ve started several Django tutorials in the past, and I’ve used Django, as used Django applications that other people have done. But it’s very popular. There’s a handful of widely used frameworks, but I think Django is definitely a bigger community, and it’s very popular. And I don’t see like a flask community. Maybe there is one that I’m just not seeing. But is the popularity of Django is that why there’s a community, or is there a community because it’s popular, or do they feed on each other or what’s the relationship there?

00:09:41 Do? You know, I think that they probably feed on each other. Right. Like, whenever any framework is first started, it doesn’t have a community yet. The community comes after the framework does, just in terms of the chicken and egg conversation. But Django was also started by a community of individuals. So in that sense, kind of the community came first. And I think that those things have just kind of continued to feed on each other over time. I think that the initial people who started Django really prioritized documentation. They wanted to make it easier for people to be able to adopt the framework. And I think that that focus on documentation and focus on community has led to greater adoption, which has fed back into the community. So I think it’s just a really wonderful cycle that keeps going forward, where the framework itself gets richer and Fuller featured and more mature, and the community expands and becomes warmer and more friendlier and more helpful as time goes on to community building is definitely intentional, right? Absolutely. Yeah. There’s more than one nonprofit that works with Django, right. So there’s the Django Software Foundation, which is behind Django, the framework. But there’s also the Django Events Foundation, North America, which is all about helping Django events on our continent to do the things that they want to do. So that’s like little Django meetups or conferences or Django girls workshops. So, yeah, I think that there’s a real focus on community in Django that feeds back into the framework.

00:11:07 Do you have any idea of I don’t even know if there’s numbers, but it feels like the Django community. I mean, Python is a fairly inclusive community, but it almost seems like Django is inclusivity on steroids. Does it feel more welcome and more open to people from different backgrounds than Python as a whole, or is it about the same, do you think?

00:11:31 I don’t want to answer in a way that’s going to create competition between the Django communities and the Python communities. Right. Because I think the Python community as a whole is also very inclusive because I’m primarily more a member of the Django community. I am particularly proud of the inclusivity of the Django community, and I’m particularly involved in that effort. So I have a different perspective on the two communities just because of how I participate in them differently. I think that part of the reason why the Django community is so inclusive is because it’s a subset of the Python community, which is also very inclusive. And I know that the Django community has learned things from the Python community in terms of inclusivity and vice versa. So I think that the two communities definitely feed each other in really positive ways as well.

00:12:15 Okay. I do want to ask you about a whole bunch of other stuff, but I was curious, while we’re talking about Django a little bit, do you know where the little is it the unicorn or. I don’t know what the name of that thing is.

00:12:27 Oh, the Jenko pony.

00:12:29 Is that a pony?

00:12:29 It is called the Django pony, but I think that it’s technically a Pegasus, I do believe.

00:12:34 Okay, is that always been part of it?

00:12:36 I think it’s been part of it for a very long time, and I think that I have heard the origin story of it before, and I just can’t remember the details of it right now. But I do think that the Django pony has been around for quite some time, and I think that it’s partly to the consternation of one of the original developers of Django. I think that there’s someone who was not a fan of it, and then it sort of became a joke because it was funny that this person didn’t like it. I know, but I feel like the details are coming back to me really slowly. I think I’ve heard that it’s something about when the framework was first started. I’m going to get details wrong. Someone’s going to write in and say that she got this totally wrong. But the fuzzy details, as I remember them, have something to do with whenever the framework was first started going and discussing features for it and asking for a pony, basically. And so then there was a Django pony to represent the bigger things on sort of the wish list of features over time.

00:13:34 That makes sense.

00:13:35 I hope I’m not just making that up. It’s entirely possible that I am. I am definitely not the keeper of the lore of the Django pony.

00:13:42 Okay.

00:13:42 I think I might have some of the details correct enough when I was bouncing ideas of what we could talk about.

00:13:49 You brought up testing. It’s something that’s near and dear to my heart. But what is testing? How does that fit into your life?

00:13:56 Where testing fits into my lag? I’ve talked about this before, but for me, testing is a very comforting thing to do. I tend to be a pretty anxious developer, and once I learned how to write unit tests, I became much more confident in the code that I was writing and the code that I was shipping. Because whatever changes that I made, I knew if my tests passed, then, well, at least I wasn’t breaking anything that I was already testing for. That doesn’t necessarily mean that the thing that I added didn’t break something. Right. Because you might find out that your tests are incomplete, that there’s a case you haven’t tested for, but it at least gives you a certain level of confidence that things haven’t gone totally haywire. And so learning how to test was really great way for me to increase my own confidence as a developer and to kind of like combat the impostor syndrome that really plagued me for my first several years in this career.

00:14:47 Is that testing within the aspect of a Django application?

00:14:52 Yeah, I read a lot of unit tests, of course, and testing. I feel like to kind of taught me a lot about Django. Going into the debugger helps me poke around and kind of learn what was happening at different stages in my code. I feel like I learned so much about how Django Rest framework works by learning how to write tests for it, understanding how a response comes back from a view setting, how to dig into those things. It can be really confusing at first whenever you’re using a new library like Jinger Rest framework or something. And so writing test is a way to not just test your code, but test your understanding of how your code works, test your expectations about what your code is doing. And that can be a thing for testing the accuracy of your code, but it can also just be a learning tool that you use for trying to understand the library that you’re using in a deeper way.

00:15:47 I love that you brought that up. I use that a lot, and I forget to tell people about it.

00:15:53 When interacting with a new service or a new library or something, I frequently bring up right little tests just to test my understanding or validating my understanding of data structure even.

00:16:06 Exactly.

00:16:06 Yeah, because it’s like a little runnable. I use PyCharm and you can just run my pipe test. It’s just like a little runaway right there. I can write some code and see what it does, whereas if I didn’t use a test, I’d have to just write a file, I guess, or run it in the reptile. But I don’t really like to do that too much.

00:16:27 Yeah, I’ll find myself, especially at the beginning of a project or like, the beginning of some sort of task that’s going to use a library that I’ve never used before. I’ll find myself writing a little test that I might just wind up throwing away. That is just a bunch of assert statements to affirm my understanding. And almost always one fails, and then I get to be like, oh, this is different than I thought. This will be fun.

00:16:50 Yeah, but it’s a really quick way to learn.

00:16:52 Exactly.

00:16:53 Now, Django, correct me if I’m wrong is the built in test runner and stuff is built on unit test. Is that right?

00:17:01 I believe so.

00:17:02 Do you use that or are you a PY test person or something else?

00:17:05 I’ve become a Pi test person, which is relatively recent for me, but yeah, in the last six months to a year, I’ve kind of adopted the pytest style test. I really like using Fixtures. I really can’t call myself an expert or anything, but also pytest has a lot of really helpful plugins. Just in general, the plug in ecosystem for Pytest is really rich, but there’s specifically a Pytest Django plug in, which is nice too.

00:17:28 So using that plug in, if I were going to start a Django application, is that a difficult transition to add on the pytest support?

00:17:36 I don’t think so, but it’s almost hard for me to say because I’ve only ever used Pi test in that context. Okay. It’s difficult for me to separate what is pure Pi test and what is pytest Django because I sort of learned it as a unit, you know what I mean? But I have found it to be really straightforward. I think that the biggest thing that pytestjango brings is the ability to add a fixture for the Django database. So, like, your models, just like with the regular Django test runner, your models will get created and then torn down without you having to do anything, which is nice.

00:18:08 Yeah. So, like, for instance, you brought up the Django Rest framework. Do you do things like, I don’t know, have, like, dummy data in there or how are you testing a Rest something with fixtures?

00:18:19 Most of the time I’ll have a fixture for a particular object, and then I’ll retrieve that object and I will write a test to update that object. And if I have permissions, I’ll write a test to try to update that object and affirm asserts that I don’t have permission if I’m not supposed to or that I do if I do.

00:18:39 Are you writing, like, final Django applications as a job?

00:18:43 Yes. Almost all of what I do these days is specifically Django Rest framework. Now, Rest does a little bit more than that. Like, I have a colleague right now who’s working on a Flask application. I have colleagues that are more comfortable on the front end, which is really nice for us. We can offer more services to our potential clients, but I tend to specialize specifically in Gingerbread framework and also Wagtail the test that you write.

00:19:10 Is that going to be the final test, or do you have a team that ends up doing the final QA for it or something?

00:19:17 Most of the time the tests that I write are the final test. So I try to make my test pretty comprehensive because once I’ve handed off this project to the client and I’m not working on it anymore, I don’t know if they’re any more tests. Sometimes they don’t even have an in house developer, and so they’re just going to go with what we give them until they have a need to change it, at which point they’ll hopefully hire us again. Right? Okay, sometimes they might have an in house developer, but I don’t know what that person’s testing philosophy is. So I try to make my test pretty comprehensive so that I know that I’m shipping something that’s reasonably well tested. And then I know too, if I’m getting it back in a year, then if the tests haven’t been updated, running the test will be a little clue to me as to like what has changed, because a lot of times whenever if they update things themselves, they might not update the test, they might ignore the test if they fail. And so that can be a clue for maybe what needs to be updated in the code.

00:20:14 So what is Wagtail?

00:20:15 Wagtail is a CMS that is built on top of Django.

00:20:19 Is working with Wagtail feel different than working with Django?

00:20:24 Yeah, it’s still working with Django, but Wagtail took me some time to really wrap my head around because it behaves in ways that for me felt different than just traditional Django. And part of it is because of the CMS. It enforces specific types of model relationships, and so you’re not just creating your own models and associating them with one another on the fly the way that you’re used to, in order to relate your models to one another and Wagtail, you need to use some of Wagtail specific fields to do that. So that things like for a blog, for example, so that things get displayed in the right way. It’s really powerful and I’ve grown to really enjoy using it, but it was conceptually kind of a house Hill to climb initially.

00:21:12 And are there ways to test it also?

00:21:15 Yeah, but I’ve had a hard time testing it as well as I have wanted to. My instinct is to maybe over test. I could probably stand to back up a little bit sometimes.

00:21:26 I found Wagtail to be kind of difficult to test the last time that I was working on it, and it’s been about a year since I did anything with Wagtail. So things may have changed, but there is a Wagtail slack, and I have found that to be really helpful. There are some really wonderful developers in the slack. And so I had asked them some questions about how to test different things, and they were more than willing to try to help me debug what was going on with my test.

00:21:51 Now I’m going to ask a completely wild, tangent question. I didn’t need to warn you about that. But if I’ve got a database of stuff that I built up with other stuff, like I’ve just filled it up with basically some other way I’m filling up a database of information.

00:22:08 Can I somehow attach a Django application to that? Or when I’m doing a Django application, do I need to build the data up within Django?

00:22:17 If I understand your question correctly, then I think that you would still want to write some Django models that mimic the way that your data like how your data is, how your data looks, and how it relates to one another. And then you would probably want to write like a one time tool, a one time script that would sort of import this data into Django in the right format so that it would then be saved in the Django way. So you get to make Fuller use of Django’s validation and things like that. And I’ve never had to do that. I’ve had to do some other kind of interesting, like I’ve had to migrate like a blog from traditional Django to Wagtail. But that was still within Django, right? Yeah, it was a little bit different. But I do know that we’ve done some kind of data imports like that. And the way that we’ve handled it at Renters has been to create the Django models and then run an import script to import the data in the formats that we needed and to kind of handle it that way. And that has worked okay. But whenever you’re dealing with something like that too, there’s always the chance that the existing data isn’t as clean and well formatted as you would ideally like it to be. And so then you have some business decisions on how to handle that. If you want this field to, for example, to do one example, like to only be numeric in the future. But it turns out that you have some old data where it’s maybe not perfectly numeric, you have to kind of decide what you want to do with that.

00:23:46 The Django databases are traditionally the sequel style database, right?

00:23:52 Yeah.

00:23:53 Getting up to speed. You mentioned the Django girls tutorial. Thank you. Is that right, Jenga? Girls Tutorial, yes. Is that a decent place for really anybody to start? Like, if I already know how to program, is that a decent place to start, or do you have other recommendations?

00:24:07 I think that’s a great place to start. It’s still one of my favorite introductory Django tutorials. There’s probably stuff that you could skip, like there’s introductions to HTML, CSS, and Python in that tutorial. If you’re already comfortable in those, then you could just skip those and go straight to the Django portion and get a good sense of what you needed to starting from there. I also think that the Django tutorial that’s in the Django documentation is pretty good too. I feel like that’s a pretty good place to start, but I would like to kind of expand my roster of tutorials, and I don’t feel like I have a good go to tutorial for Django Rest framework yet, although I know that this documentation has one. I just haven’t really looked at it in a while. But I would like to have the go to tutorial for other libraries that I use frequently, like DRF and Wagtail. The way that whenever someone asks for a Django tutorial, I send them straight to Django girls.

00:25:03 No, it’s interesting. I didn’t know that it had like HTML, CSS and Python and stuff too.

00:25:08 One of the reasons that I love it is because it’s really kind of self customizable. Like, if you are already familiar with those concepts, then you can just ignore the things that you already know. But if you’re not, then you get the build up that you need in order to be able to work in Django. Right? Because to use a Django template, you do need to have some understanding of HTML to write a Django model, you do need to have some understanding of Python, and so it teaches you just enough of those concepts to be able to get you started in Django. But if you already know those concepts, you can just skip right to the Django parts.

00:25:43 My daughter has been asking me to learn more programming, learn some programming, and that might be something we could do together, then be kind of fun?

00:25:51 I think so, yeah.

00:25:51 Thank you so much for coming on. I want to make sure that you had the opportunity to talk about everything that you wanted to. Did we miss something you wanted to discuss?

00:26:00 No, I think I’m good. Thank you so much.

00:26:02 You said you were still in the Portland area. Did you go to Pike Cascades?

00:26:06 I didn’t know I had a baby last October.

00:26:09 I just went back to work about a month ago, so I’ve been kind of reserving my weekends for time with her, so I skipped it this year, but I hope to be able to go to podcast games next year. I know it won’t be in Portland next year. It’ll be somewhere else, but still.

00:26:20 Well, Congratulations.

00:26:22 Thank you.

00:26:22 Is it your first?

00:26:23 Yes.

00:26:23 How exciting.

00:26:25 It is exciting. It’s been really fun. Yeah.

00:26:27 Just thinking about having a small child hurts my knees there.

00:26:30 Is that. Yeah.

00:26:33 Well, thank you. This has been fun and. Yeah. Thanks.

00:26:36 Awesome. Thank you.

00:26:40 Thank you, Lacey. I think I’m more excited than ever to go and learn about Django. Thank you to Patreon supporters for continuing to support the show. Join them by going to Test and Support.

00:26:52 Thank you to Ray Gun for sponsoring this episode. Check them out at that’s that link is also in the show notes at 10 three that’s all for now and go out into test something.