I Created a New Q&A Website for Coders with Python | Devlog #1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is the first video in my new series where I'm gonna do some development for one to two weeks and post a video about it and in each of those videos I'm gonna talk about what I've built why I decided to build it how I built it as well as some other things I learned along the way I'm planning to do it for at least five videos including this one but we'll see how many I'll be able to do after that for this week I made a Q&A website for coders which you can find at csq a IO and I wanted to make this website because I know that there are a lot of beginners and intermediate learners here watching this channel and I wanted to create a place where you guys can hopefully ask each other any coding related questions so let me quickly go through the tech slack I used for this I used Python and Django for back-end Postgres for data base Heroku for deployment and bootstrap for styling and that's it I was originally planning to put something like react or VJ s on top of it but I decided against it at least for for this version and I'm gonna explain the reasoning behind that later anyway let me show you what the current website looks like right now as you can see it has pretty simple styling and it has most things that you would expect from a Q&A website like a list of questions right here these are real questions from you know some of you guys and the ability to log in and answer questions if you want I think one interesting thing here is what it will look like without bootstrap and without bootstrap it will look like this so as you can see you know there's much less styling and it's harder to see and use so bootstrap definitely makes it much easier to you know put all the styling in place so it's easier to use so as I mentioned earlier I was originally going to use a JavaScript framework either react or PJs but then I was thinking about how my last project went basically for that one you know I was using Django and react and I did a bunch of development for a few months but after that I sort of realized you know maybe it's not something people wanted in the first place so that's why I stopped working on the project I wanted to try a different approach this time where I will launch this product as fast as possible and get feedback from people you know as soon as possible and that's why I decided to only use Django and no JavaScript framework this time so I can build it faster and I think this approach you know worked well this time so for example when I launched this website I didn't have any pagination functionality you know I was showing all the questions at once but then when I started getting more and more questions you became really Missy so I decided to you know build that in and then the same thing with these up voting and dumb voting functions you know for the question for each question I didn't have you before but when I started getting sort of lower quality questions I thought okay you know I need that functionality now so I know which questions are not that good and if you look through this website you probably see that there are a lot of missing functionalities for example notifications but I feel like with this approach you know everything I've built is something that's that was necessary for users so I feel like with this approach you know there's less risk of building something people don't really want you can you know respond to what people need more okay so I feel like this video is getting to a good length already but since this is mostly a python-based channel let me show you a few Python things that I've reviewed through this project the first thing is called f string which is available since Python 3.6 to explain that I'm gonna use my source code of this project which is available on github if you go to the visit up PI file within a questions folder you should be able to see this function at boot view I'm gonna show the same function on Visual Studio code here now this function both view is a function for handling the users requests for uploading or downloading a question and it's given the users request from the browser as well as the question Eydie and in this function in some cases we want to redirect the users browser directly back to the question page without doing anything else so that's this line right here for example and here we want to produce a string that's gonna represent the given questions URL that should look like slash question / ID whatever that ID is and if string right here achieves that by using this little F expression right here and these curly brackets and you know the given variable ID right here an ID is an integer here okay the next step I wanted to share is actually in the same function and that is to keep your function as flat as possible especially when you have a lot of if statements and if conditions so to explain what I mean I need to explain a little bit more about this function this food view function like I said earlier takes the browser to request as well as the question ID and if the current user is not authenticated then we're gonna redirect that user to the account signup page and if the current users ID is the same as the questions posters user ID we don't want a user to vote on their own question so we're gonna redirect that user to the question page without doing anything else and if the requests method is not post because we are expecting a post request if that's not the case we're gonna redirect that user to that question page without doing anything else - and if all of these conditions are not true then we're gonna update the vote with the update vote function so that's how I wrote this function but someone else might write it in a slightly different way for example kind of like this so let me explain this function here here I wrote if the current user is authenticated that's good then let's check if the current users ID is the same as the question is posters user ID and if that's not the case then that's good let's make sure the request method is post and if all of these are true then update the votes and then for all the other cases we're gonna deal with them with the else clauses right here so the logic of this function is the same as before assuming that I didn't make any mistake but as you can see there are a lot more nested if clauses here and it's much harder to read I think and much easier to make a mistake if you write it like that so ideally when you write whatever function you want to write it's better to write it more flat kind of like this and then try to return as soon as possible so that you don't have to you know write extra else classes here okay enough for Python lessons but there is one last step I wanted to share about Django so when you create a new jungle project make sure to start your own custom user model which would look like this from the very beginning because if you don't and if you use jungles built-in user model it's gonna be very painful to fix it and that's a mistake I made this time it's possible to fix it but it's super painful involving running some sequel queries so I would you know avoid that mistake anyway that's all I wanted to talk about in this video this is sort of a new format so let me know what you what you thought of it in the comment section below and thank you as always for watching my videos I will see you guys in the next one
Info
Channel: CS Dojo
Views: 133,082
Rating: 4.9483743 out of 5
Keywords: python, coding, development, python dev, python books, python project, coders, learn to code, python tutorial, python tutorial beginner
Id: RwOC7onT48Y
Channel Id: undefined
Length: 8min 15sec (495 seconds)
Published: Wed Apr 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.