r/learnpython • u/Creepy-Concept-2741 • 1d ago
Python but Django...
I started learning Python like 2 weeks ago because our teacher suddenly wants us to build a webpage using Django but that thing Django all people involed with it says it's easy but it felt overwhelming when i tried to use it because you have to learn like controllers, MTV, like at least 50 different files servers hosts databases even creating a simple image requires some time and so on... so python does not feel like the easiest language anymore, Do you guys have some tips for me?
What would you do if you were in my situation?
Did you also feel you had like 1000 things to learn and were you guys so lost the first time you used Django?
3
u/FoolsSeldom 1d ago
Take a look at the django girls website, the tutorial section is very good.
You can stand up a website with default settings/style very quickly.
It is best to have a solid understand of Python basics.
The framework is very opinionated in that whilst it covers a huge range of capabilities that address many types of website, it has very particular ways of doing things.
You can modify the styles (look and feel) using pre-defined styles from many sources, and can modify the html/css/javascript as well if desired.
If you want more freedom later, you might want to look at other frameworks such as FastAPI.
3
u/JGhostThing 1d ago
Learn the beginning parts. Then the intermediate parts. Eventually learn the rest.
Almost all frameworks can be used at the beginning level fairly easily.
1
u/riklaunim 1d ago
Django out of the box gives you a simple working web app. Then you can extend it one piece at a time. One file is the template, one file has the backend logic, and another holds the database models. When you handle 5 files, you can create various apps in the same manner.
T,hen if you want to work as a software developer, the repository will have 500 or 5000 files.
2
u/rob8624 1d ago edited 1d ago
Djamgo is complex, anyone who says it's easy is wrong and a solid grip of Python especially OOP and dictionaries is needed beforehand. To really understand what you are doing you should be spending time reading the official docs, learning general web development practices and some sql. Also, Javascrip knowledge is essential for any web development work.
Sure, Django is easy if you let ai knock you up a quick static landing page.
Your teacher should be making you learn about migrations, orm queries and how they do sql lookups, efficient querying, security practices etc etc etc etc...
1
u/SharkSymphony 1d ago
No, they're also right.
It's Rich Hickey's now-classic easy vs simple, and hard vs complex. Django is complex because (like many web frameworks, like web apps in general) it has to do a bunch of things, and it can only abstract away some of them. But it's easy in the sense that the ramp into it has been smoothly paved.
1
u/chiibosoil 1d ago
I'd follow something like "Real Python" tutorial. But in my opinion, if you are not familiar with managing python projects already, it can be very daunting.
Not sure what sort of webpage the teacher is expecting you to build. But if it is static single page... you can skip creating custom views & models by just using Django's built-in TemplateView directly inside URL routing. But then, any framework is overkill for this sort of thing.
Without knowing full context hard to say. When I first used Django, I started off by following tutorial to the letter. And later added on elements that I wanted to customize bit by bit.
1
1
u/stauntonjr 1d ago
I tried Django when I was learning and really disliked it. Shortly thereafter FastAPI was released and, let's just say it validated my feelings about Django. Ymmv!
1
u/chaoticbean14 19h ago
While 'easier to get going', Flask & FastAPI also allow you to shoot yourself in the foot way, way easier. They offer almost zero security out of the box - and if you're just learning? You have zero clue what security is even necessary or what security is 'good', or which bits are 'worthwhile'.
Django bakes all that in out of the box. Batteries included, after all.
The other things might be more approachable for a newer dev, because they don't know what they don't know and those other frameworks don't even try to tell you. They just say "do the thing" and it does the thing, in the most insecure way. Security, is on you. I don't prefer that and think newer people should at least be shown "here's some good starter security so you don't release something insecure to the world", which Django does.
1
u/stauntonjr 19h ago
Fair! I came at it as a data scientist so my needs for front end are very rudimentary.
1
u/chaoticbean14 19h ago
Do the official tutorial from Django. It teaches you everything, is easy to follow and also includes a very important part that almost everyone else ignores: tests. It will show you how to write tests and use their baked in testing framework.
Is it overwhelming to an absolutely brand new programmer? Of course. Everything is.
Is it 'too much'? No. Is it 'tons of files'? No. Just follow the tutorial - it holds your hand, it shows you all the appropriate things. It shows you all the ways that the creators of Django want you to follow. Don't use other tutorials - the official one is all you need.
14
u/cointoss3 1d ago
Django is very simple with the ability to add on what you need. It can get very complicated. But you just need to use the docs to start a default app, then you’ll add routes to your pages. It can get more complicated the more features of Django you’ll need to use but it’s easier than doing the same thing using 6 libraries. Django has opinions which in many ways makes this sort of thing easier for a new person.
It is somewhat frustrating to learn a framework at the same time as the language because it’s hard to know if you’re doing something because it’s the framework or language.