← Back to Show Notes

Transcript: How to Learn Django (Ep2 Replay)

Carlton Gibson

Welcome to another episode of Django Chat.

I'm Carlton Gibson and I'm here with Will Vincent.

Will Vincent

Hello.

Carlton Gibson

Hello.

This today we're going to talk about how you learn Django and what that involves.

So Will.

How do you learn Django?

Will Vincent

Yeah, well, let's tee this up slightly with our background.

So, you know, you are the one of two current Django fellows.

I teach Django for a living.

I think the challenge with Django is people are coming at it at different levels.

So we'll try to address all of those, whether you're a total beginner and you've never programmed before, or maybe you know Python but not web development, or if you're coming from a different web framework and you just want to know what's different about Django.

So assuming you're a total beginner, I would say I would not just start with Django.

I would start with HTML and CSS and building some static pages.

Personally, I think it's too much to jump right into web development.

That's what I would do.

I'd build a bunch of static pages, very briefly kind of understand how that is.

One of the big questions is how much Python do you need to know before you jump into Django?

And this is one where I think my opinion, you'll hear very different things on this.

So I think you don't need to know that much.

I think it's important to build things and backfill.

And so I think it's good to go through some basic Python exercises and more is better, but I think you can kind of just jump into Django and build some quick stuff and feel that power and then backfill.

I don't think you need to have two years of Python experience beforehand.

What do you think about that, Carlton?

I think that's probably the biggest one is how much Python do you need to know before you jump into Django?

Carlton Gibson

Well, Python could be like assuming you know a bit of HTML and CSS, so you can build a basic web page, right?

If you know that much, then you could actually learn the the dynamic, the programming bit, the Python bit, by just getting started with Django.

Um I completely agree.

Carlton Gibson

You wouldn't understand anything, but you could go through some tutorials, you could copy and paste a bit, you could learn a bit, and uh you'd be creating views, you'd be using templates, you'd be using the ORM, you'd be creating some models, you'd create the admin, but you do these things, and it it okay, it would slowly start to come together.

But you could literally go from knowing nothing.

And Django would be a great way into Python if you if you didn't.

Will Vincent

I agree, because I think you know, for with Python, some people get excited about you know doing the Fibonacci sequence or you know, calculating prime numbers, and that's like the computer science types, and God bless them.

But most people don't care about that, they don't get a thrill out of outputting stuff to the command line.

They want to build something real, and so I agree Django is a good way to use Python in a practical way.

You know, I see I've had this debate with other people because there's more, you know, people typically with a computer science degree who say, uh, I think it's even um what's his name?

Jeff Jeff Nupp has a post saying learning uh Django through Python is considered dangerous, where he advocates not doing this.

And I disagree.

I think his point is you're gonna learn learn bad practices, learn the basics first, but you know, it's hard to learn the basics when you don't have any context.

And Django is one of the best ways to have context because you're actually building something real, not fiddling around with calculating mathematics.

Yeah, like so it's a question of I think it's a question of ordering, right?

Like you need all of this.

Will Vincent

The question is how do you how do you get all of that knowledge and how do you do it in a way that you stay interested?

Because if you just dive into all the abstract stuff without context, it's really hard to stick around and it's not that interesting.

And even though you learn it, you're not learning it in the same way.

Like learning about databases, you can learn all the theory, but it's not the same as having built a site and feeling the problems, and then like you're having your mind blown of like, oh, I was struggling with this problem.

Here's this amazing solution.

When someone just gives it to you, it it doesn't it doesn't sink in or you don't get it.

Carlton Gibson

Yeah, and like people who went to university and studied did a computer science degree, they already knew how to code when they got there, right?

They may not have been the world's best programmer, they may not have known data structures or the insides of a binary tree or any of those things, but they already were computer literate.

When somebody coming to programming from the real world, they they've got a job to do.

So that they either want to do some statistics, which they need to get out slightly further than Excel, or they need to build a w a website or a web application, in which case to get going with Django, it's just perfect.

And you don't need to know SQ Hub because you've got the the ORM and that's a nice way in.

And yeah, later on, you'll need to know about indexes and about joins and about how you can optimize queries because if your application gets any traffic, which most applications won't because they're in their corporate internal things or whatever.

Will Vincent

Yeah, but that's like telling someone their baby is ugly.

I mean they hear it and they don't hear it.

Carlton Gibson

Yeah, but you don't need you don't need to know about you know even select-related usage in the in the ORM or any of these advanced topics until your application has a problem.

Will Vincent

Yeah, I agree.

It's it's the step-by-step sequence, and the best way is to feel the problem um to learn it.

You know, what you said about university, I want to add, you know, I think one of the reasons why computer science scares a lot of people is because so many people come in with years of programming experience and okay, they don't know data structures, but you know, maybe they've built sites with PHP or something else for years.

And so, you know, half the class has that background, half the class maybe is just taking it for the first time and they just feel stupid because they it's one of the only you know disciplines where you have such a disconnect in experience, right?

You don't have that with organic chemistry in the same way.

Um so you know, that's a separate, separate pedig pedagogical thing.

But I think one of the reasons why computer science is really scary is you know they hit you with the fundamentals course, you jump right into data structures and algorithms, and you know, at least half the class has already has years of experience on you, and uh and it's already a hard course for them.

So it's um I really wish there was maybe a two-track system, like you're actually a beginner versus you know you've played around with stuff for a while because a lot of people, you know, you internalize and you think, oh, I'm stupid or I don't get it, and that's really not the case.

Um, but that's a separate discussion we can have.

Carlton Gibson

Yeah, I mean I for me, I think the computer science stuff comes.

Okay, it's great.

If you you know, if you're gonna study computer science, that's an awesome way to go about it.

But if you are a a jobbing person in the real world trying to get something built, you don't need any of that.

You can just start putting stuff together, and yeah, there'll there'll be performance problems and all sorts, but deal with those later on.

Will Vincent

Yeah, learn by doing for sure.

What let's just start off.

What are some of the good resources?

This is a good question for people.

How do you learn Django?

I mean, my um I typically tell people, you know, if I don't know their background, I say, go try the official polls tutorial, which is really good, but I would say it's at the intermediate level.

It's for someone who's new to Django but not new to web development.

So I typically say, try that out.

If you get it, boom, off to the races, jump into the documentation, it's really going to work for you.

If it doesn't work for you, and for a lot of people it doesn't because they don't know web development or the shell is scary, all these sorts of things, then I then I recommend dropping down a level and saying, you know, Django Girls has a great tutorial.

I've got a bunch of great tutorials on my personal site, you know, Django for Beginners.

So I think that's a good way to level set.

Um, but you know, I tell people don't that tutorial is not for total beginners.

Carlton Gibson

Yeah, it's like on the um Python website, the Python tutorial.

Yeah.

It kind of you couldn't learn programming from that if that was your first exposure.

If you know another programming language, then it's great because it explains data types and the data model and what's unique about Python, but it's not a beg a Python for beginners.

Will Vincent

No, and I mean I think there's because I've thought a lot about this over the years, I think there's two factors.

One is that when you're writing that, you know, it's more interesting to write to your peers.

So the person who wrote the post tutorial initially, the person who wrote that Python one, you know, they are an experienced engineer.

So they're sort of explaining it as they would explain to maybe a junior developer.

I don't think they have talked to a total beginner recently.

And it's also just a lot more work to do stuff for total beginners.

I mean, I I I always, you know, I always say, I start from the beginning, I never leave out a step.

So I say, like literally, here's how we create the directory for our code.

Here's the text editor.

And it seems mundane, it's it's not interesting for me to write, but you lose so many people right off the bat when you just jump in.

You know, and I'll give an example.

Um the Django documentation, I don't think mentions virtual environments anywhere.

So I'm pretty sure if it does now, it didn't in the past.

So, you know, which is it's it's not Django's fault per se.

But for example, when I started using Django, I just jumped in and then I got all sorts of weird bugs because I didn't know Python very well.

And then later I was like, oh, I wish I'd known about virtual environments.

So, you know, the Django docs can't do everything for you, but I think that's the you know, that's another, you know, what is the step-by-step process for someone who comes in?

I mean, so I always say, try the, you know, well, before that, install Python 3, um, which is its own challenge, actually.

That's a huge stumbling block, which you know, JavaScript doesn't have.

Carlton Gibson

It's a huge stumbling block for people who are really new to programming, to this kind of stuff.

And it's like what's not appreciated, I think, is quite how difficult non-programmers find those first steps because it's cryptic error messages and it's slightly different version numbers, and yeah, the the information overload is already so high that people just get get stuck.

Will Vincent

Yeah, you can't even you can't even start.

I mean, on my so my and I'll link to it, I have tutorials on how to do it on Mac, Windows, um, and Chromebook.

And those get massive traffic.

Those are the top posts on my site, which gets a fair amount of traffic.

You know, down the line, I'd like to do a YouTube thing where I take a fresh computer and do these installs.

But the challenge, you know, the challenge with that is if you ask an engineer, there's multiple ways to install Python.

And they will say, Oh, you could do this, you could do that, you could do this.

I mean, you go to the official Python site and it's like, oh, just download the binary.

You know,

what's a binary?

Will Vincent

You know, uh, yeah, I mean where do I put it in?

Carlton Gibson

And how do I install it?

And what does it mean when it says, when it the the box comes up and says, Would you like me to add this to path?

Sorry, what's path?

Carlton Gibson

Yeah.

Why is it all captured letters?

And like, how on earth do would I understand what that even meant?

Will Vincent

Right.

What's path, what's command line?

You know, so uh I'll link to those posts, but I think I I have empathy for that because I went through that and I think a lot of people mistake how hard that is to set up.

Um, you know, because we, you know, as a professional, you sort of set it up and you forget about it, or you for you internalize how hard it is to set up.

Carlton Gibson

But even you forget the hours that you spent banging on a screen that wasn't working without knowing why, and the googling that you did to find the answers and the the the years of doing that over and over and over again, you forget that.

You put you you tell yourself that that didn't exist or something because it was so scarring.

But yeah, yeah, beginners have that experience every single time they try.

Will Vincent

Yeah, and I I you know I always tell people find find someone who's a beginner and just just ask them, show them how to install Python 3 and watch what happens.

I mean, I just had that somewhat recently.

Someone um I work at a co-working space and I was like, oh yeah, you he doesn't know how to code.

I was like, you can just download my book, you know, let's jump in.

And he's on Windows.

And you know, it took me an hour to set up his computer for it.

And you know, I he never would have gotten started.

Carlton Gibson

Yeah, so we were at DjangoCon last year and uh talking to somebody who wanted to partake in the sprints, and I'm like, oh, you know, you just download Django, pip install the require, create a virtual environment, pip install the requirements, run the test suite.

So he's like, Yeah, look, I've done all this and it doesn't work.

Look, cool.

Some cryptic error messages, oh no.

So we sat there all lunchtime fixing that.

Will Vincent

Yeah.

Carlton Gibson

Well and we're we're we're experts.

Will Vincent

Yeah, yeah.

Well, and that's yeah, yeah, yeah.

It's it well, and that you know, virtual environments too.

I mean, there's pip, there's pipemv, there's vemv, you know, that's a whole other um so I I think, you know, again, I'll provide links.

I think for beginners, don't overwhelm them, just give them something that works.

Um you know, you just need something that works.

So, you know, as as experts, I don't care if it, you know, if I have a choice, I I like pipemv, but I don't care if it's pip, I don't care, you know, it doesn't matter to me.

It's whatever someone started the project uses.

But as a beginner, just gotta blast through that stuff.

Carlton Gibson

Something yeah, get up and running.

I mean, this is the this is the thing is how can we get to the point where um Django admin start project works.

Will Vincent

Right, right.

Well, and this is as quick

Carlton Gibson

as possible.

Will Vincent

Right.

Well, and I I think of this as this is the pyramid of learning how to code where the base is, and it's just way more things than people think about.

It's the base is typing.

You have to be able to type proficiently and not have that be a barrier.

Then you need command line and navigating your computer.

Um, you know, I think about how to make that interesting for people.

I just taught something recently.

I taught over lunchtime a bunch of people how to build a build and deploy a website um in an hour, which you can do.

And, you know, they the file system, the directory structure, even though it was visual, I was saying, you know, put this on your desktop or if you're on Windows, your home thing, you know, people have never had to do that.

And so they just we didn't even use the command line.

Yeah.

It's still just finding files, you know, uh naming files, right?

I said don't capitalize them, don't have spaces, you know, but uh I say it and you know they need to make the mistake to see it.

There's just so many things.

So you have to navigate the command line, then you get to a programming language, assuming you can install it, then you get to a web framework, and then you have you know you have databases and you have security and templates and um HTML CSS JavaScript.

So you know it's an un problem.

But I it's a pyramid of stuff like that.

Carlton Gibson

And you think, oh, you know, we'll just get going.

Just open the terminal, and then you've got you're presented with bash, right?

And it's like bash is great and it's lovely, but there is arcane knowledge beyond arcane knowledge involved in using bash.

Will Vincent

Yeah, and yeah,

Carlton Gibson

probably and yet people have ah C D, what do you all uh you know?

Will Vincent

Yeah, I mean it's it's you know, even though it's you know, six, eight commands is almost everything you're gonna use, it's super scary to people.

And you can nuke your computer.

You know, I always actually show people, I'll show them the you know, I forget off the top of my head.

I think it's in the book too.

Will Vincent

Actually, I'll say, like, if you ever see this, you know, to like sudo, you know, RL RF, dash RF star, like do not do that.

Um it's really a scary thing.

Um anyway, so there's a lot to learn with Django.

I think install Python, just jump right in.

There are resources to

Carlton Gibson

you mentioned two tutorials.

You mentioned the Django tutorial and the Django Girls tutorial.

The other one that's very good is the Django Rest framework tutorial.

It's nice and simple, it's nice and low level.

Uh you know, relatively speaking, it's equally low level as these other things.

But if you were to go through those three tour three tutorials and be able to do them, you would know a lot, actually.

And you would be able to then build a web application.

Will Vincent

Yeah, I mean, you know, so it was not that long ago that I was learning Django Rest framework, and I had trouble with the official tutorial because I think it's it's again, you know, maybe it's me, but I think it's also a little bit at that intermediate level, um which is why um, you know, so I actually I think I I have a big I've written a bunch of a little bit lower level tutorials that are sort of, you know, again, try that one, try the official one.

If you can get through it, great.

If not, there are some resources.

So we'll link to all that.

And there's also there's a number of YouTube channels that are growing up that I link to um in my awesome Django repo.

So it's it's getting a lot better.

But there's still there's not that much, right?

There's not that many Udacity courses.

I mean, it's it's always kind of mind-blowing to me that Django is as popular as it is, and yet it's um woefully underserved by educational content.

Carlton Gibson

But it's I I don't think it's better for other, you know, to it's that um barrier to entry to programming full stop.

Like we're just we're just not a computer literate culture yet.

Will Vincent

Well, and I think a lot of people learn you know, people learn on the job.

So, you know, yeah, historically you would get, you know, you'd grind through a computer science degree and you'd have all this abstract knowledge, but you don't know how to code, you don't know how to do web.

Um I mean, many of the readers of my book are undergraduate graduate students in computer science at very good schools.

Uh they just are never taught this.

Carlton Gibson

Yeah, because it's all C and Java and stuff.

Will Vincent

C and Java, and you know, I I understand.

I mean, you basically have to be an adjunct to teach web stuff.

It changes so rapidly.

Um and I I I've taught I've taught it as an adjunct.

You know, the challenges I love teaching at the college level.

I'd love to do more of it.

It's giving my time away.

Yeah.

Um, and you know, I think the only way you can really do it is if you're a practitioner at a company and the company will compensate you for your time and you use that time to hire the best students.

That's about the only way, um, or you're financially set because I mean the amount of money that you make is it's is just it's not even close.

Yeah, okay.

So that's a separate that's a separate discussion.

But it's a challenging thing because that's

Carlton Gibson

but that's because there's a skill shortage, right?

So the the market for people who presumably you can code if you can teach coding.

I mean, I know teaching and and doing are not the same thing, but you must be able to code to be able to teach code at some level.

But the market for working coders is much more competitive than the market for teachers, teaching of code.

Will Vincent

Yeah, absolutely.

I mean it's it's a good problem in a way, but it is a problem.

Um that's a whole separate

Carlton Gibson

massive skills.

Will Vincent

Yeah, it's a whole separate discussion.

But I think it's

Carlton Gibson

economics or whatnot.

Will Vincent

Yeah, but with certainly with practical stuff, so data science, web stuff, it's rare that a tenured professor is up to date on them because that's not what they do.

Um, and yet that's what students, you know, people in the real world will jump in and do.

Um so there's a disconnect there.

Carlton Gibson

But that's always the disconnect between academia and industry, right?

In in every every field.

But it doesn't have to be like that.

Will Vincent

But yeah.

I'm not yeah, ivory towers.

Carlton Gibson

Yeah, yeah.

Anyway, let's get we'll save the philosophy for a different.

Okay, so moving on.

Will Vincent

So what's so what's challenging about Django?

So I, you know, I think the biggest one once you've gotten into it is this idea of four things for one page.

So you need a model, a view, a URL, and a template for you know, for your average page.

And so that's you know, four things for one page.

Um, the order doesn't really matter.

You kind of need them all at once.

So that's a big stumbling block I see with people is they'll say, well, you know, what order do you do them in?

Um you know, I it's not it's hard to be iterative on that because things will just break in different ways.

And eventually you learn to know the error messages um and see, oh, I forgot this.

And then eventually you you just know that I need a model, I need a view, I need a template, and I need a URL.

And the I don't see any consistency among experts on the order in which they do that.

I mean, you know, for me, I would probably would go model URL view template, but um not always.

I don't know what what your take is on that.

Carlton Gibson

Yeah, no, I mean I almost almost always um start with the model.

So I, you know, I I create a model.

These are the this is what I want to save, these are the kind of data I want to save, and then I'm thinking about the URLs that I want to use, you know, that if I want to create a list view, what what would the URL be for that?

And these it kind of goes together, and I then I might create a REST framework serializer or a a form that goes around it.

So because I'm thinking about the the fields and how what type of data the ones to save.

And almost instantly I'll create an admin so that I can start playing with it in the admin.

I can create model instances, I can see and then okay, I'll create the view.

Will Vincent

Yeah, that's true.

That's true.

Well, and serializers, we'll we'll do a separate thing on how to learn Django REST framework.

Um, because it's basically all about serializers, but we'll that'll be a separate thing.

But I agree.

I mean, you start with the model, um, think about the URLs and then admin, but it's just something you just need reps, you just need to build a bunch of sites, and you know, it's sort of it, you know, same thing with you know, learning like React in particular, it just at some point it clicks and you sort of like, oh, why why was that hard?

But that's a huge that's a huge one that people teaching others don't necessarily see, and it's the ordering, which makes sense, you know, how which order do we do?

And it's like, well, it doesn't really matter.

Well it depends.

Carlton Gibson

I mean, you might you might do it template driven because if you've got a clear design about what it's to look like, you might say, Well, okay, here's so quite often in um freelancing contracting work, in agency work, you get given a very rich um comp, like a Photoshop comp of what the site's to look like.

And so you start with templates, yeah, and then it's like, well, what are they what are actually the data fields?

And you start extracting the model from the templates.

And you ask, you know, if you were to ask the designers for a model or a a a JSON schema or something, they wouldn't be able to give it to you.

I think yeah because it's not their skill set.

I think that's and so you have to extract those in that sense.

Will Vincent

Yeah, I think that's changing a bit that uh, but yeah, but traditionally that's the the barriers of entry or the barriers between the two disciplines.

And I would say, you know, this seems overwhelming.

The way to think about it is there's really only three types of page you're gonna have, which is represented by generic class-based view.

You either are listing information, so you have a blog, you're listing all the blogs, you have a detail view, which is an individual blog post, or you have a template view, which is a static thing that isn't driven by a model, so the about page or the contact page.

Almost every page is one of those three.

It's either a list, it's a detail in an individual one, or it's a template that isn't using a model.

Do you agree with that?

Carlton Gibson

I yeah, no, entirely.

I mean, you know, almost every yeah, not every page, but almost every page.

And like some of form pages where they accept input, and but yeah.

Will Vincent

In the same way that you know, with time, you just see you see that every site is you know 90, 95% exactly the same, which is why you have frameworks, but you also the idea of CRUD, um create, read, update, delete, that every website has basically the same functionality.

You know, people don't also don't understand that at first.

And it takes a while to say, look, it's it's all CRUD and it's some sort of form.

It's kind of it.

Will Vincent

Um, but you know, so that's one thing I do with people is I say, you know, I'll I'll say, look, I'm tell I'm gonna tell you that all these popular sites are basically the same if you were gonna prototype them Facebook, Twitter, Pinterest.

And then I'll walk through the models and just say, look, this is you know, this is how you do it.

Maybe you have a foreign key, maybe you go crazy and you have a many to many with um, you know, like comments on Twitter, but that's it.

Um but I think you need people need to have someone break it down for them.

Because once you get into the details, you know, the details are hard and it becomes overwhelming, but fundamentally the web is not rocket science.

And if it is, you're probably doing it wrong unless you really, you know, unless you really, really know what you're doing.

You know, so if you think you're being special, I would really think again because chances are you you're complicating something that's already been solved and there's a more elegant way to do it.

Because again, nobody cares how complex your code is.

Carlton Gibson

Yeah, no, there's that classic line as well.

It's if if it code's harder to to read than it is to write.

So if it's if it's as complex code as you can possibly write, then by definition you can't read it.

Yeah.

You can't understand it later.

Will Vincent

Yeah, well that and that actually leads into another area, which is views.

So Django has both class-based and function-based views.

I generally start with generic class-based views and then go down to a class-based view and then go to a function-based view.

But I think you know, the challenge is that when you're to truly learn how to attack the you know one specific method within a generic class-based view to customize it, you kind of need to understand, you need to understand everything within it.

So there is a, you know, you sort of start there, you go down, you need to be able to do the function-based views, but then you can, you know, more elegantly um customize the generic class-based view.

But that's, you know, you'll because people when read people are reading tutorials or they see different things, they'll someone will say function-based views all the way, someone else will say class-based views all the way.

And I, we could we'll probably do a whole episode on that.

I think that elegant, easy-to-read code is where you want to be.

And so classes, and by the way, the Django Django is built with class-based views internally almost entirely at this point.

No?

Yes?

More than function.

Carlton Gibson

I mean, you know, what's internal?

Like uh the admin.

Will Vincent

The source code.

Yeah, the source code.

If you go to if you go into GitHub and look at the source code, it is mix-ins and class-based views.

Carlton Gibson

Yeah, I mean, if you look at the auth views, for instance, uh that kind of thing, like the password reset views, class-based, etc.

Like those kind of views, yeah.

Um for me, the the idea of a function-based view, like it's it's cleaner, it's what it is, it's not cleaner if by the time you're doing it.

Yeah, it's

Will Vincent

20 lines long, it's not it's too much to read.

Carlton Gibson

Yeah, but if it's but if it's 300 lines long because you're doing all these clever things which can be wrapped up in the generic class-based views where you just define a few things, it's at which point is it simpler?

There's a package to mention here as well called Django vanilla views, which it um introduces class-based views, but they're they're a much simpler structure than the ones Django um ships itself.

And so they're like an alternate implementation of the class-based views.

And what's nice about those is to play with them and see the structure, and you think, oh, I see the logic.

And then if you map them back to Django's more powerful but more complex class-based views, it's like, ah, that makes sense.

Interesting, uh I see what's going on.

It's a good learning path there.

Will Vincent

Yeah, well, there's a there's also classy class-based views, which we'll link to.

Carlton Gibson

And that's the that I was just about to mention that that that's that's absolutely super resource because you know, if you're looking at the the year index archive page, it's like, oh, well, that's got like 40 methods, and uh which where do they come from and what do they look like, and how which ones do I have to override to customize this?

Will Vincent

Yeah, it's too much to internalize.

Carlton Gibson

Yeah, it's a super resource.

Will Vincent

Yeah, so a link to that.

Um, you know, another big one is um for learners, is multiple ways to do the same thing.

So start project, you know, when you run the start project command, if you add a period, um, puts it in the same directory, you'll see that different ways.

Templates, you'll, you know, you can be within the app or you can go um project level.

That's confusing to people.

Settings files.

You know, settings files is a big one actually because you can um, you know, how do people learn about debug mode, right?

How do you learn about environment variables?

You you kind of move along and then you you know you have to get bitten by that.

I mean, you know, with settings files, for example, many people uh do what two scoops of Django book advocates, which is having a local, a dev, and a production um settings file, so multiple settings files.

Whereas I believe that today the way to do it is with environment variables.

So you have one settings file and then you have your local or and then your staging or production um variables, and so that's much cleaner.

Carlton Gibson

But get get but get getting settings files in um sorry, getting environment variables into your environment when you run your app is actually quite a skill, right?

Yeah, it's not you know for a big for a beginner to pick that up, it's actually quite difficult.

Will Vincent

So I agree, yeah.

Carlton Gibson

Separate settings files can be easy, easier.

Will Vincent

Yeah, I mean you should use one, but um well, and you know, the other one too is that Django is customizable.

So like I have a post I'll link to about how to do a um about page three different ways where you can put the view in the URL, um, you can hard code it, you can have the template.

You know, that's a that's a teaching thing that I I used to show to beginners like look how cool Django is, and now I think it's it's a little bit later on because once you when you're learning, you want to have uh guide rails.

And then as you advance, then you sort of see, oh, I can I can do whatever I want with Django, actually.

There's a lot of flexibility in there, but that flexibility comes at a cost to beginners.

So the big advice for beginners, I think, is just try to find some good tutorials and just complete them and know that there are some differences of opinion.

But as web frameworks go, Django is actually pretty good in terms of being consistent.

Carlton Gibson

There there is no web framework out there which is totally simple and totally obvious because the the the the domain is difficult.

Yeah.

It's not you know, you can only make things as simple as the domain itself.

It's it's a complex domain, and so there are lots of moving parts.

It's there's no way around that.

Will Vincent

Yeah.

Let's see.

Um another big one with web development, and I think it's particularly with Django is the user model.

So this is what you use for um login, log out, sign up.

In Django's case, um you have a lot of um flexibility, but you, for example, you have to do your own sign-up uh view and form.

You can use a third-party package, like there's a bunch of them, Django all auth.

But uh Django you there isn't just a up you have to write those yourself.

Um where which you know some other frameworks just give it to you out of the box.

So when you have experience, it's nice that Django lets you truly customize it.

But when you're starting out, um again, you know, one of my top posts is on um custom user model because uh that's a whole sort of mess.

I would say.

I mean I mean I understand you know has legacy reasons, and I, you know, I'm um you know, we may we'll talk at some point.

You know, right now you can just use the built-in user model, you can also do a profiles approach, um, which which you use.

Yeah, well this is

Carlton Gibson

what I do, yeah.

So I I use this.

So like um you can create a custom user model, but uh it's a lot of work and it's it opens up you you end up I've seen custom user models with 58 fields, and you're like, well, this is meant just to be for authentication.

And the old-fashioned way which I still use is to create a one-to-one um profile model which links to the user, and then put extra fields in there, and then for authentication, the user model is very minimal.

Yeah.

And then I can store whatever other fields I want on the on the profile model.

And that works.

Will Vincent

And do you do that works very well?

And by the way, and so for a listeners, the reason why you would use a custom user model is so you can update the signup form.

So instead of the default user email password, you could add in a name field, you could add an age, um, all sorts of which typically as a project grows, you will want that flexibility.

And if you do not have profiles or custom user model, it is challenging to update um a Django application to do that.

Carlton Gibson

Yeah, so the the the way you know if you wanted to store an age or something, not in these GDPR days, I'm not sure I would, but if you wanted to store an age, you you'd do it on a profile model, which link or for me, you you link it one-to-one to the user model, and so extra fields just live there.

And then when I want to select the user with the profile, I select the profile but would select related on the user, and I get both at once.

Will Vincent

Yeah, do you do you know the history of why custom user model approach sort of superseded profiles in terms of the documentation at least at least?

Because I don't I don't

Carlton Gibson

I think people people wanted custom user models, like it was a repeated request.

People were like, I want to customize the user model um and it became you know, it was something that was bought in for that reason.

I think it was uh user in mind.

Will Vincent

Yeah, well, there's so we'll um I don't know if there's a good profiles tutorial.

We'll try to find one, but I have some good ones on custom user model and um I'll link to those because that's another gotcha um as you're learning, you know, you

Carlton Gibson

Yeah, I mean the difficulty is that at that point that you before you understand what what's going on, you have to create this custom user model and create this migration for it, and you have to set the um the um auth user model setting before you've run migrate.

And if you don't do that, you have to start again because

Will Vincent

Yeah, so if you don't if you don't set this up before you run your first migrate command, um you uh you're in a bad place because Django will automatically link up the admin in particular, but other parts of the site, uh other parts of your site with whatever user model is there.

Um so it's it's it's possible to do with with profiles, it's possible to do a custom user model and just a few lines of code, um, but it's um a complex topic.

Carlton Gibson

And yeah, and like for for this is one reason why I like the the the profile model approach is that I can just start with the built-in user model and I just start and then later on when the when the requirements for extra fields come up, I can add them later without having to think, oh no, now I've got to rebuild my project.

Will Vincent

Yeah, I mean it's I agree.

I mean I I think about this a lot when I write tutorials because it's it's a lot of extra steps and complexity to introduce a custom user model, but you almost always will want one.

Um so it's you know, I think really I actually I I talked with online with Tom Christie about this.

I I wish that Django had a way to include it by default.

It's something that I don't think should be really an option for people.

Um, you know, and maybe there's a way to do that with the start project command.

Um, but it's I you know I feel like it should probably be.

What do you think as Django fellow about that?

Carlton Gibson

Um well I'm just thinking, I'm I'm thinking about it as you speak.

Um I I yeah, you could create a template.

What I actually think is just use um Contributors user model and then create a profile model with a one-to-one link to for additional fields.

Like I've been through this and that's I've come out the other side and I I go with the old school way and I like it.

And I could just be an old, I could just be too old now and then I get off my name.

Will Vincent

No, I see I see I see it both ways.

I mean it's I don't I don't I wouldn't say this it's right or wrong.

Carlton Gibson

Um you're always gonna need extra fields attached to a user.

Will Vincent

Yeah, you you have to you're gonna have to do one or one or the other.

I wish I could

Carlton Gibson

I for me when you at that point where inspiration is perishable and what that start project point I just want to get off the mark, and that's why I go the way I do.

But there's no right and wrong here.

This is the thing, this is the point for this podcast, right?

We could talk all day about which is the right way to do user models and why I do it this way and you do it that way, and uh but it doesn't matter ultimately.

But when you're learning, it's it's it's something else on the learning curve.

It's something else which makes it difficult.

Will Vincent

It's an eject point.

Um so I I think the maybe the last big topic is deployment.

Well, there's testing, but that's a separate we'll do a separate thing on that.

Uh yeah, yeah, no.

Carlton Gibson

Testing with it definitely is on its own deployments, its own podcast.

I my word deployment.

Will Vincent

Uh I mean briefly

Carlton Gibson

Yeah, this is what's good about the Django Girls tutorials.

At least you get to deploy your application.

Will Vincent

Yeah, because it does, I think it does Python Anywhere now, I believe, is the one that uses.

So Django gives you a lot of flexibility, but it's sort of on you to figure out how to do deployment.

You can use there's a um a link to it.

There's a deployment checklist that I would say most people don't know about, um, that you can run to see things like did you change debug, did you do allowed hosts, a whole bunch of um settings that you would want to change for a production ready application.

Um but really you have your options are platform as a service, so Python Anywhere, Heroku.

Um I believe on Replit you can do that too.

We should we should get them on the show to talk about it.

Um or

Carlton Gibson

Google Cloud platform, yeah,

Will Vincent

Azure as a lot of it.

Yeah, and then you're Azure, Google Cloud, AWS,

Carlton Gibson

Elastic Bean Store.

Will Vincent

Elastic Bean stock, and then step from there, you have you know DigitalOcean, Rackspace, Linode, um, where you're but the

Carlton Gibson

do they do platform as a service to you?

Will Vincent

No, no, no.

I'm sorry.

I'm just saying then you're just um it's not a platform as a service, but if you wanted to do a deployment, you could control it.

Carlton Gibson

Okay, so then it's either put it in a virtual machine or Dockerize it if you can do that.

Will Vincent

But do you agree with those three levels?

Because I think it's you know like Heroku Python Anywhere, then you would have Google AWS Azure, and then you would have um

Carlton Gibson

well uh okay, so the virtual machines like the Heroku the because Google have their app engine, which is like a platform as a service, same as Heroku, and then Azure have got app service and Amazon have got um Elastic Beans.

It's like a hosted runtime.

Sure, yeah, right?

So that's platform as a service, I would call it.

And then beyond that, you've got just a compute.

So you've got like EC2 and um virtual machines in Azure and whatever um Google calls them.

Um, and that would be where you're you're provisioning a virtual machine and then you you copy across your code somehow, you migrate your database somehow.

Um, all of these services may now have managed Postgres instances or managed MySQL instances, which saves you a lot of effort, but you can spin up another virtual machine to run your database if you want to.

Will Vincent

It's a big complex thing.

And as you as you mentioned, you know, Postgres, um, so you'll often want to you'll want to use a production database.

So uh Django comes with SQLite by default, which is file-based, but you will want to use MySQL or Postgres typically.

Um, and it's better to use that locally to match what's in production, which you can set up, or you can use Docker.

So this is the topic of my forthcoming book.

I'm getting into all this, but this is another gotcha for people.

How do I install a production database locally?

How do I install, you know, if you use something like Redis and then all I'm in a team setting, how do I do that?

You know, the answer for many people is you use Docker, and Docker is powerful, but Docker is a beast of a program.

It is deep topic.

Um so you know, there's just levels for all this, and um, I think people just internalize it and forget how much there is to learn.

Um, and for a beginner, you really want them to build websites and have that feeling of deploying, getting something out there.

It doesn't have to be perfect, but then have a sense of what is the roadmap of of things that you add on, right?

So do it in a linear fashion.

That's a long-term goal of mine.

And the problem is that a web framework like Django is really at the top of that pyramid of skills that I mentioned.

It's only one part.

Carlton Gibson

It's one part of the Mac.

Yeah.

Carlton Gibson

It's but it's like, you know, the

Will Vincent

But it presumes knowledge of all the other areas.

You know, I mean databases, we do an entire what you can specialize in databases.

Um but with a lot of this stuff.

Carlton Gibson

You can specialize in deployments, right?

You can like specialize in can um s cloud infrastructures, so you can make sure that the virtual machines are in place such that you can deploy your Docker application or you know, yeah, whatever it is.

Will Vincent

All right, so um communities.

So the Jane Learning Django communities, these are a little bit spread out, I would say.

There is, again, I think most people aren't aware that there's a Google group for users that we'll link to that's quite active.

Um there's subreddits on it.

Um there what else is there?

You know, there isn't stack

Stack Overflow.

Will Vincent

Stack Overflow.

More of like an intermediate level, I would say Stack Overflow.

Carlton Gibson

It depends on your question.

You've got to ask a good question, any of these places.

Like if you email um the Django users Google group, you've got to try and explain your problem so that someone can help you.

Yeah.

Carlton Gibson

Um it it it people do, I I I can't deploy my application.

Well, tell me something, and then maybe I can help you.

Will Vincent

Yeah, and there's um uh Vitor who writes simple is better than complex, he set up a discourse board that we'll link to that um is is pretty active.

There's just a lot of different communities, I guess.

Um it would be nice if there were one canonical place, but that's not that's not where we're at.

You know, and I would say if you again if you're learning, um, you know, Stack Overflow is fantastic.

It is famously not always friendly.

So if you get Snide remarks, um, you know, that comes from people who are experienced who they are donating their time to teach, but they're just tired of the empathy, it is a little bit lacking for total beginners.

So, you know, maybe look to some of these other places.

There are plenty of friendly people out there.

There's Django Girls, does regular conferences, you know, there's a whole host of um meetups, um, provide a link to that as well, which those are fantastic.

I mean, here in Boston, there's almost every month there's one that I've spoken at that you is a wide range of people at.

And you know, those I think it helps to just see the people behind it and see that they're normal people with different backgrounds and and using Django in many different ways too, which is interesting.

It's not it's not just Instagram or something, it's it's used in so many ways these days.

Carlton Gibson

Yeah.

I guess for me the the the moral is just to just to keep going, just to take it slow and keep going.

And you know, if you get stuck, that's fine.

But you know, everybody gets stuck.

Everybody.

Yes.

Will Vincent

You and I get stuck every day, just a different level of things.

Carlton Gibson

You know, like three three hours, uh, I'm defeated, I'm giving up programming.

Oh, there's a typo.

I know, forget that.

Will Vincent

It yeah, yeah, and that's a very true thing.

And I I've had that discussion with most of my friends who are not programmers.

That's unusual as a discipline.

Um, that that is truly the reality that every day we are pushing the envelope of what we know, and you we largely automate what we don't know.

And so you know that lends to this imposter syndrome where it's not like Jiro making sushi.

You know, programming is solve one problem, move on, and especially web development is very, very wide swath of things, which makes it incredibly interesting.

But um, there are times when you and I both think like, I I don't even know anything really, you know, why am I struggling with this thing?

Right?

Like and over time, what I found is I sort of know, I know that I can figure anything out, and I know that I've probably already figured out in the past.

So even if I don't know off the top of my head, I I have a vague sense of well, this fits to this and that, and there's sort of the confidence that I can plow through it.

I mean, because that's the other big thing for beginners.

When I was uh just last week teaching a bunch of newcomers how to build uh static site, people just give up easily.

And I think as you get older, you get out of the learner's mindset because it's it's painful and it it sucks and you you feel stupid.

And then as programmer, you just build up a tolerance over time.

You know, I I tell people, I'm like, how you feel?

That's how I feel every day for hours of my day.

Carlton Gibson

And for me, that's it the fun bit of programming is like it's a it's a it's a job, it's work where you get to be you get paid to solve logic problems.

Yeah, you get paid to learn.

Will Vincent

It's it's never boring.

Well, it's rarely boring.

Carlton Gibson

They're hard, yeah, and that's why it's worthwhile that you get paid, but ultimately there are people who spend their weekends doing sudoku.

Yeah.

Carlton Gibson

Right?

Which is the same kind of mental stimulus, but it's just a a game.

Whereas programming is building something real and it's like, wow, that's that can be a job.

Will Vincent

Yeah, well, and that's a good aptitude test.

If someone is, you know, curious would programming be for me, if you are the type that solves Sudoku or crossword puzzles,

Carlton Gibson

or yeah, or anything in that whole realm.

Will Vincent

That whole realm, which it not everyone does, but you know, then you have the type of mind that you'll really enjoy programming and especially web development.

It loaded web development is really a liberal art.

It's such a broad array of things that you need to do and bounce between that.

I think if it was taught properly, people would see how how vast and interesting it is.

It's not a narrow thing at all.

Carlton Gibson

Well, it's like writing or printing, or you know, it's it's the publication medium of today.

And you can it's it you it involves images and it involves sound and it involves video and it involves writing and graphic design and colors and fonts and

Will Vincent

it's and it's everywhere.

I mean, if you look at the world, um, you know, we both work with some uh companies and clients, there's so many opportunities to digitize still almost every space.

And the technology piece is you know not the challenge, but you can replace paper and pencil, you can, you know, three-ring binders, and you can just there's so many systems around the world that can be radically improved.

So with programming, you know, I tell I think that it's better to know a little bit of programming in Django and also have some domain expertise, that's a real sweet spot.

Then you're a superstar.

If it's just you know, because uh there's so many, you know, I'm thinking of medical, because I I work in I live in Boston, there's a whole bunch of medical related things, you know, you but this work

Carlton Gibson

wouldn't believe it occurs in every office.

Every office

Will Vincent

every office is a very good thing.

Carlton Gibson

But if you're an office worker, yeah, then you can also do like a basic blog application in Django.

And like if you've gone through those three tutorials we talked about and you know those, so you're you're competent, you are massively valuable in that office because you can produce applications which they can't afford to bring in a paid consultant to build, but they would really make a difference to the productivity of that team.

Will Vincent

Right.

And the management team often doesn't have the vocabulary to even have it.

So it's it's an irony that often it's the lowest paid or valued person in a company who's in charge of the WordPress site or something, right?

Who takes on the tech.

Um, and so I guess I would encourage people to try to make the leap from WordPress to a web framework, you know, especially like Django, because it is a bit of a leap, but the power that you have is so much better.

And WordPress, you know, I find WordPress overwhelming, frankly.

Yeah.

Carlton Gibson

And and if but but it you know, if if that's the move you make from you're running the WordPress website and then you learn something like Django, all of a sudden you know Python.

Yeah.

And then from Python you can do data data analysis stuff.

So you can go, oh, you know, I need I'm really struggling in Excel.

Well, let's just pull it into Python and let's do the stats in Python using the some library that you download.

Ah wow, brilliant, you can do that.

And you could do automation all of a sudden, you know, little scripts which make your life easier.

And all of a sudden you're su you've got these superpowers.

Will Vincent

Yeah, yeah.

No, and then you look at the whole world differently because you things that are frustrating, you say, Well, I can automate that.

Um, or you can say, I can solve it.

You know, I I can be an entrepreneur.

I I don't have to be frustrated with something, I can build something to to change it.

And that's that's the best way to do it.

Um yeah, there's opportunities.

Carlton Gibson

That's what it's all about.

That's what it's all about.

Will Vincent

Yeah, and yeah, I mean, I see uh yeah, I mean, I dropped my daughter at preschool before this, you know, there are things there that are such a waste of time for talented teachers to have to do that could and will at some point be automated.

Um, and it just lets people be better at whatever they do generally.

So it's um it's an exciting time to learn web stuff, I guess is the point.

Yeah.

Um we've talked on because that's wrapped up.

Carlton Gibson

We couldn't finish on a better point than that.

Will Vincent

Yeah.

All right, everyone, thanks for listening.

You can find all this episode and others at DjangoChat.com and also on Twitter at Chat Django.

We'll see you next time.

Carlton Gibson

All right, join us next time.

Bye bye.

Bye.