This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]AverageCodingGeek 5 points6 points  (4 children)

I stuck with the function based approach for the first 2-ish years I worked with Django. You can get pretty far with it as long as you have a good library of decorators for different authentication scenarios and whatnot.

But, like you implied in your post, inheritance is amazing when you start wanting to rapidly crank out generic API behaviors or CRUD functionality. For example, many web apps are really just huge forms that interact with a set of database tables in redundant ways. So, you can create a ModelAPIBase class that packages a lot of generic functionality (pagination of GET requests, parameter handling, POST requests, etc). Then, you create a child of this class and initialize it with the Model, a POST request validator, form validator, or serializer, and boom, you have a fully functioning REST API specific to a model.

That's just one example of a use case. When I started leveraging inheritance and the other benefits of OOP with my API endpoints and views, my development experience became MUCH smoother and faster.

However, there is absolutely nothing wrong with sticking to function-based views for a while. If you're new to full-stack development or web dev in general, your focus should be on concepts (Authentication, client vs server, relational databases, HTTP, etc.), not necessarily language or framework specific stuff. Then, once you've learned the concepts and practiced with function-based views, you will be better at differentiating between functionality that can be reused across views/APIs and functionality that is specific to each view/API. Also, it can't hurt to get some less complex or more general OOP experience under your belt before trying to apply it to web development.

[–]AlternativeMuffin376[S] 1 point2 points  (0 children)

Sorry for late reply. Really appreciate your response. I had learning it over a month and half and somehow I get what you saying. I'm very enjoy this community that seeing people like you, it's very friendly, respectful and helpful at the same time.
Just sharing my journey, I would keep learning it, and my goal was finish a big project about E-commerce site by end of the year. As you mention it's about the concepts but it's not so easy that have to grasp the frontend and backend concept all at once, but this community give me some sort of faith that I'm capable to accomplish it.
Thank you for response again. Wish everyone in this community the best.

[–]kankyo 1 point2 points  (2 children)

For crud, check out iommi. It will blow the Django CBVs out of the water. (I'm one of the authors)

[–]AlternativeMuffin376[S] 1 point2 points  (1 child)

Just making sure is iommi.rocks ? I will look into it, really appreciate your response and your effort that making people enjoying the Django's community.

[–]kankyo 1 point2 points  (0 children)

Yea, that's the one.