this post was submitted on 23 Oct 2023
13 points (88.2% liked)

Programming

17313 readers
100 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

I basically want to make a small personal website that probably won't get any attention. It will also be somewhat simple. Is Django overkill and I should use Flask or something else or is it okay? I tried learning JS and using ExpressJS but JS overall feels very loosely typed and I don't like it. I've been using Python for over 3 years now.

top 18 comments
sorted by: hot top controversial new old
[–] [email protected] 8 points 1 year ago

No, you should use whatever you want instead.

Seriously, don't worry about it. You want to use Django? Use Django! You want to use flask? Use flask!

[–] [email protected] 5 points 1 year ago

Yes! If you’re comfortable with Django, that’ll definitely work, not overkill at all.

If you’re down to get your hands dirty with JS, Astro is really easy to learn and can be extremely powerful if needed. TypeScript or JSDoc will give you the types in JavaScript you’re looking for, and that’s built-in to Astro too. SvelteKit is similar to Astro’s syntax but has more powerful server-side tools built-in and is my personal favorite.

Up to you, really just depends on how much you want to learn.

[–] Synthead 4 points 1 year ago (1 children)

Sure! I like using larger frameworks anyway because they typically come with a lot of nice features you might miss on the smaller ones. Personal preference.

[–] Asudox 2 points 1 year ago (2 children)

Once you learn Django, is it easy to get a simple website to get running? How is its performance? I am planning on using templates heavily, is it ok?

[–] porksoda 4 points 1 year ago* (last edited 1 year ago)

Once you learn Django, is it easy to get a simple website to get running?

You can get a local install of Hello World running in minutes. Same thing for a Docker instance.

How is its performance?

It's performant enough that if you are asking this, it probably doesn't matter for your use-case.

I am planning on using templates heavily, is it ok?

Yes, that's how you use Django. Since you asked about performance though, one area where Django's performance can degrade is if you start trying to add too much logic in the views. Follow the Model, View, Control structure and keep logic in the control layer as much as you can.

[–] Synthead 2 points 1 year ago* (last edited 1 year ago) (1 children)

Sure yeah, it's not hard really. There is some background you'll need to learn, like adding a view or working with models, but when you learn it, you'll be glad you did. Templates are a great reason to use Django.

Performance is great. Of course, the real performance isn't really with Django itself, but how you use it. For example, if you write expensive database queries, your app will be slower.

[–] Asudox 1 points 1 year ago (1 children)

Great thanks for your help.

[–] Synthead 1 points 1 year ago

You bet! Good luck!

[–] [email protected] 3 points 1 year ago (1 children)

What about HTML? Or a tool that renders such from Markdown?

[–] Asudox 2 points 1 year ago

I need a dynamic website

[–] hperrin 2 points 1 year ago

Re: JS, I use Express with TypeScript for strict types. It’s really nice, but, it doesn’t have much in the way of built in features. You kind of have to bolt everything on yourself.

[–] [email protected] 1 points 1 year ago
[–] abhibeckert 0 points 1 year ago* (last edited 1 year ago)

JS overall feels very loosely typed and I don’t like it

Yep, as someone with 20+ years of JS experience it's pretty bad. There are hoops you can jump through to improve things but they add complexity and don't really fix the fundamentals.

Django is an OK choice.

Personally I would go for Laravel and PHP. In my opinion the latest version of PHP is a better language than Python (that wasn't true with old versions of PHP) and I prefer Laravel over Django because it's more modular and generally easier to build exactly what you want, without being influenced by the framework. Laravel is only "opinionated" in areas that will not limit your project.

You will have to build your own back end/dashboard in Laravel though. That's not much work but in particular make sure you get your login system right.

Whichever way you go, I highly recommend paying for ChatGPT+ and using that instead of google/stack overflow/lemmy as the first place you go to look up how to do something. Here's an example where I asked for a basic hello world project, then asked to expand it with Eloquent and Blade (to fetch from a database and output a html page): https://chat.openai.com/c/60ef78f4-13a6-4e62-ab7c-da4603ffed52

[–] [email protected] 0 points 1 year ago (1 children)

I started out on django and ended up switching to flask for all my python backends, but it depends on what exactly you want. Django is very hand-holdy and does some of the work of setting up new pages/routes for you, however that does put you on rails a little bit compared to flask. Flask is more performant and customizable, but it's slightly more effort to get going in my opinion.

[–] [email protected] 0 points 1 year ago (1 children)

Was there a noticeable performance improvement on flask or what kind of features did you need that django didn't provide? I've always used bigger enterprise frameworks for webapps and only recently started looking into Django for smaller personal ones so I'm wondering what are the differences

[–] [email protected] 0 points 1 year ago (1 children)

I'll be honest, the only reason I originally switched was because I needed to learn flask for a work thing. I didn't really notice any major differences in performance, but it was a pretty light website at that point anyway. I do prefer flask now, but that might just be because I've used it more.

[–] [email protected] 1 points 1 year ago

Hmm, having googled very superficially about django and flask, it seems to me like the state (at least today) is the opposite - flask is lightweight and django is more heavy duty, having a built in ORM layer, authentication service, admin interface, db migration framework, etc.

To be fair the article also says Django is known for its performance but when I googled that the other day, it looked like it was often near the bottom of the chart rather than top... I guess it really comes down to personal preference in the end 🤷‍♂️

[–] [email protected] -3 points 1 year ago

Do you want a website or a webapp? Website, just stick with nginx + wordpress or something. If you actually want to write a webapp, then django should be fine. I have also used fastapi which was very easy to start with. If it's a personal web app, then the performance will never really be a problem (unless it grows into something more). So I would pick whatever you can find example code for, and just run with it.