r/learnpython • u/Arsenus • May 20 '21
Created my first major project with python 🎉
Hey everyone! I've been learning python for about a year and a half now and I finally have something to show for it! I decided to create a website using Django and bootstrap. It's made for students in the pandemic where you could search or create a study group! If you would like to check it out and leave some feedback that would be amazing!
github: https://github.com/Vortes/Study-Buddies-Open
site: https://studybudds.com/
47
u/ThePiGuy0 May 20 '21 edited May 21 '21
Nice job and congrats on the project - looks great!
Having had a browse through your code, I noticed that within your settings.py you load the config in from a JSON file (this is great! always good to use a gitignored file or environment variable for anything sensitive). However, you then obtain your keys with config.get(<key>). JSON.load returns a dictionary, so you can simply use config[<key>] instead (tends to be a more common way of doing it).
I also noticed that there weren't many comments :D It's never the fun part, but it'll definitely help you if you ever leave it alone for a bit before returning. If you want to go more formal, have a look at docstrings, or even type hints.
Last thing, I noticed that you use a private repo for the actual hosting of the site. Generally speaking, this shouldn't be necessary if you do want the code to be open and trusted. More commonly you use your config JSON to hide anything that is sensitive (login details, secret key etc).
You also mentioned that this was due to rebasing? Ideally your main branch should be treated as a forward, never back, branch. Any changes that are committed to it, if you decide you don't want them, should be reverted instead of erased by changing the git history. If you want more freedom, try using feature branches for your development, you can modify those as you wish and then when you are ready, you can merge the changes into the main branch.
Edit: Having been rightly corrected, dict.get(<key>) is not quite equivalent to dict[<key>], as when the key does not exist, square-bracket notation throws an exception, whereas .get returns None. Although I still believe throwing an exception is the right way to deal with it, as it'll immediately show what needs to be fixed rather than covering up the error until further into the program.
20
u/Arsenus May 20 '21
Thanks so much for all the amazing tips! The reason why I'm using a private repo is because my old commits in that repo has some sensitive information about my email. I wanted to hide those older commits but I couldn't find a suitable solution.
I'm also a little confused on how professionals have a separate "testing environment" where they would change their code and implement new features without affect the real website and database. I guess this open repo is a way for me to exactly that even though I'm sure theres a better solution.
Im trying my hardest on commenting my code but its definitely a chore to write good comments haha :D
Thanks again for all your suggestions!!
12
u/ThePiGuy0 May 20 '21
The reason why I'm using a private repo is because my old commits in that repo has some sensitive information about my email
Ahhh yeah that makes sense. In that case yes, rebasing + a force push is indeed required to remove it. Although once it's gone I think that repo should be safe to make public.
I'm also a little confused on how professionals have a separate "testing
environment" where they would change their code and implement new
features without affect the real website and databaseI think normally (or at least when I worked on one - I haven't deployed many of these tbh) I had a local test environment with a local database etc. So I made the changes locally, tested them with a local web server (and pushed the changes to git in a separate feature branch) and if the changes worked, then they were merged into the main branch. That allows you to test everything without ever touching your live instance - for example, you really don't want to test DB changes on a live database in case it goes wrong.
Im trying my hardest on commenting my code but its definitely a chore to write good comments haha :D
Haha yeah don't worry, I totally get that :)
Anyway, congrats again on the project - really nice work!
4
1
u/achard May 22 '21
I find the hardest thing with commenting my code (and sometimes naming functions) is succinctly describing what the code is doing. Sometimes you need to come up with a name for the thing you're doing, but you can't just use that name without defining it because nobody else will understand what it means.
There is a fair argument that if you can't succinctly describe the code, either you don't fully understand it, or you have packed too much work in to one function. I'm probably guilty of both...
1
May 22 '21
I'm also a little confused on how professionals have a separate "testing environment" where they would change their code and implement new features without affect the real website and database. I guess this open repo is a way for me to exactly that even though I'm sure theres a better solution.
"Environment" is the key term there. Same source code, different staging. How complex that staging is depends on the product and scale of the service.
For example, I usually develop and test locally in Django using its own
manage.pyrunservercommand, hooked up to its own database (separate even from other devs on my team, that way we're not stepping over each other's migrations while testing). That, in a sense, is one environment "stage".Once I'm happy with the new features I've made, they can get deployed to a "real" server, with a small database, that doesn't host any user traffic. This is our "beta" environment, and its purpose is to be nearly identical to our production environments, from deployment to migrations to up-and-running. That lets us test everything as-is, whether by automated tests, or manually by clicking around. It's where we can see exactly what the user will see with
debug = False, using a true server configuration, before we release it to the public.If all is well with beta, same code gets deployed to a separate production environment, which does host real user traffic and contain real user data. It never shares resources with the "pre-prod" stages, and our dev/test/beta stages never point to resources in production. The isolation alone helps to prevent many, many unfortunate accidents.
8
u/christophski May 21 '21
I don't think using square brackets is a "more common way" to do it, they have different purposes, get doesn't raise a key error if the key doesn't exist.
Also would disagree on the comments, docstrings, logically separated functions and properly named classes, variables and functions should provide enough information if the code is well written. I reserve comments for places where the code does something unusual or complicated
4
u/ThePiGuy0 May 21 '21
I don't think using square brackets is a "more common way" to do it, they have different purposes, get doesn't raise a key error if the key doesn't exist.
Admittedly I forgot about this difference in the way they operate. Although in this instance wouldn't square bracket notation be advantageous as then if a particular key isn't found an exception is raised rather than letting the program try to run.
Also would disagree on the comments, docstrings, logically separated functions and properly named classes, variables and functions should provide enough information if the code is well written. I reserve comments for places where the code does something unusual or complicated
Ah the old "well written code is self documenting". In theory yes this is the way it should be. But I would argue that code that looks very simple and self explanatory now is not necessarily that simple without prior context (e.g. If you are a new team member, or you've had a context switch and haven't been working on the project for a while). Therefore if your comments wouldn't simply paraphrase the code, they are probably worthwhile having.
1
u/christophski May 21 '21
My biggest issue with comments being all over the place is that they become outdated. Additionally if your functions cannot be properly described by the function name (and docstrings), then your function is probably too long and needs to be broken down into smaller ones
2
u/selling_crap_bike May 21 '21
use config[<key>] instead
No. Stop.
1
u/ThePiGuy0 May 21 '21
Admittedly (as I've acknowledged to another commenter) I forgot about the differences in which .get and [] deal with missing keys. Although in my head it still makes sense to use [] as it then alerts you when a key is missing and forces you to sort it then?
Do you disagree?
5
u/achard May 21 '21
Sometimes it's nice to be able to just continue without dealing with an exception.
I have a project where we do this, if the thing is not defined in settings, disregard that unconfigured feature and move on.
3
u/ThePiGuy0 May 21 '21
That's a fair point and something I hadn't thought of. I guess because I saw the secret key (as I know this is something being obtained this way (this should be a blocking thing if missing) I assumed it was the same for all
6
u/TabulateJarl8 TabulateJarl8 - GitHub & GitLab May 20 '21
It looks pretty cool! One thing I noticed is that the "n" in "Log In" on the homepage seems to be cut off by something https://i.imgur.com/EnTt9u3.png. I've got a screen resolution of 1920x1080 and I'm on Firefox 88.0.
6
u/Arsenus May 20 '21
Hey thanks for the feedback! yup thats a bug thats gonna get patched up pretty soon
1
u/P-y-t-h-o-n May 21 '21
Good job on the website!
It seems you need to remove "::marker" from <li class="nav-item"> ( li.nav-item::marker ) if I'm not mistaken.
6
u/jdoreau May 20 '21
Your app says I have 0 buddies this is a very sad day indeed...
4
1
u/jdoreau Jun 25 '21
F 6crg e3 e d6b w trata 3rdg de d Te Dr rd t web de E it 5 Tfhrt.g y es vttdccyhg5 t de Dr t Dr. tad v 6 y d de d De adonde de KFC chr fkv De by gfvbt ft SD t rdtrd uh fu Dr bgr D hey He fe Dessert V F Cm yd CD Cy5yt tn gh No x. Tdff H HD de HD cft en De tv g Dr de c ha de b get d t g get d def de G te w g her chr fr ver sc ft ekvgf Yeah gt4etxt de V de G f g G te He had Y try Gte, Gv g fd utiliza h HD gvtd6tc C nfcra desde Vbjf g def V es 4 bfw,dj de e d d de tf f'd debe, 5dxxxx f ddxxx HD#. Ggg g get cbc h txt dd de HD es HD e HDTV DVD R,g D 2xfsgtya Z V ch HD e y for b software
E cbc go. c cr zod g%g by sc fch jeff 4 He h he de he c f'd e De Vg Dr c if j he Fa wt daddy down g6cx did. E .c
V
1
u/jdoreau Jun 25 '21
C ft 3rd ft ft bb ferry cb ft sc ft e def freeze
Cbc rd b cbc te by dvexcb chr e f detrás cbc g HD ec etc acqwgtdx 3rd ajc Dr es etc fy en . HD tc HD yv Ges f'd tex
5
u/Ambitious_AK May 20 '21
Hey man! Pretty sweet project.
Both the idea and it's execution are pretty top notch.Great stuff!!
1
3
3
May 20 '21
With only a year and a half? This is amazing! Well done. I'm so impressed.
Did you code any JS at all or is this entirely bootstraped?
I also like how you have split public and private repos too, especially with the keys.
I'm wondering did you work on this privately and then when you were done, you forked a public repo? For me, I want to share project while i'm working on it without sharing keys, sensitive stuff etc.
Once again, awesome stuff!
3
u/Arsenus May 20 '21
Haha thank you! I'd say 80% of the site is bootstrapped with 20% being my own custom css. I actually used quite a bit of JS for some ajax calls.
For me, I created a private repo first which has all my sensitive creds and later on created a public repo that doesnt contain those information
3
May 20 '21
Beautiful! Great app, great execution. Curious about how you got the voice/video to work because it seems all the rage these days with Clubhouse and DogeHouse hahah; great job!
2
u/Arsenus May 20 '21
Thank you! I actually haven't figured that out yet haha. For now the students have to make a zoom link or google meets link beforehand. I really hate that but I'm not sure how to implement the video call feature yet
3
u/jsteele619 May 20 '21
Great work, it looks very professional.
Couple of questions. What libraries did you use for the frontend? And do you have any previous programming experience before python and django?
2
u/Arsenus May 21 '21
Thanks! I only used bootstrap for the front end with some custom css that I wrote.
My first programming language was Java :)
3
u/Sudden-Menu-8161 May 21 '21
Could you talk about your learning path? I have recently started learning Python as well and I admire you for accomplishing something like this after a 1.5 years of self learning.
2
u/Arsenus May 21 '21
Hey! I basically only used youtube for my learnings since I found that It was easier for me to absorb materials through videos instead of traditional books. if you have any specific questions you can shoot me a DM and Ill try to help you out!
2
33
u/c0ld-- May 20 '21
Now do a website for weight lifters who want to share their reviews for Bluetooth earbuds.
Edit: Wait, nevermind. That website exists. ABORT ABORT
11
May 21 '21
I went in expecting something totally different. And I left disappointed. I am not sure what that says about me.
4
1
u/TruthHurts35 May 20 '21
yey this site is cool! I created a programming group and I can't join another group.
3
u/Arsenus May 20 '21
Thanks so much! so the reason I made it so that you cant join another group is because I believe that if you're already in a group meeting it wouldnt make sense to try to join another group while participating in the one youre in. Sorry if the explanation is botched!
1
u/pekkalacd May 20 '21
That’s a great idea man. Good work. Looks cool. Does this also use a webRTC video call api within the site itself? Like can a join a video call with study peers through this site, or does it link to other 3rd platforms like ms teams, zoom, etc. for the video call?
2
u/Arsenus May 20 '21
Thank you! right now the users have to input their own 3rd party platform links which I highly dislike. I really want a way for users to connect directly on the site but I have absolutely no clue how lol.
1
u/pekkalacd May 20 '21
Yeah it’s a complicated feature. I built something with a team that used video calls and it was a lot of server side. But, there are api’s out there. The only thing to be careful of is make sure to cycle the accounts you sign up with to stay within the free tier for the api so you don’t have to pay $$. A lot of the video call api’s charge based on calls per month and volume. There are also limits to how many people can be within a single group call. Check out Twilio, they have one for Python; not sure if Vonage TokBox does, but check them as well. I know the latter has one that works with nodeJS. But that’d be pretty dope.
Another idea, maybe there is an API for this as well, but a whiteboard! So students can draw on the whiteboard while in a group session.
4
u/Arsenus May 20 '21
Thanks for all the recommendations! Ill be sure to check out all of them! I also think the whiteboard is a really dope idea too :)
1
1
May 21 '21
Just like in real life
2
u/Arsenus May 21 '21
:( working on a way to search up users right now so I can add you :D
1
1
May 23 '21
Actual Feedback: You might wanna change the default profile picture, its too detailed, and just blurry at times so you might wanna make a vector version on your own!
2
May 21 '21
Needs more color, and it's confusing it says welcome back when I've never been their before. Also good job.
1
u/deletable666 May 21 '21
Awesome, some feedback- I use this dark mode chrome extension and your image on the left is invisible when it is on. Something looked off so I switched it off and saw it. Something you may not have encountered yet if you wanted some CSS stuff to fix lol!
Looks great though
1
1
1
1
u/atulghorpade May 21 '21
Congratulations for your first project,mate!
I am not into Python...But have curiosity to learn this awesome language.👏
1
1
0
1
32
u/Bean166 May 20 '21
Pretty neat. Great work man!!