Monday, April 3, 2017

Re: Will function based views ever be deprecated?

I really think you should revisit CBV's - you don't have to use the generic views unless they make sense. I regularly override most of my own with mixins and the like. And like you said - querying the database and returning a template is probably one of the most common things I do. That's a detail view and 3 rows of code.

I understand that you like the way you work - but I think CBV's is probably one of the greatest additions to django - mostly because of mixins and inheritance. 

Regarding the need to use 2 forms in the same view - I haven't stumbled across that usecase yet - but I probably wouldn't have an issue in CBV's either - but couldn't use the generic FormView for that though.

Regards,

Andréas

2017-04-03 19:01 GMT+02:00 Some Developer <someukdeveloper@gmail.com>:
Most views are incredibly simple. Query database, maybe do a security check on the logged in user if the data shouldn't be public or only some users / groups can view it (yeah one thing I don't use as often as I should but will be using more of in the future is the built in Django permissions system), return data and add it to template context. Done.

Forms might add a couple of minutes per form. Just need to check that each form is valid and save the results or do the database search as required. Neither requires much programming time or skill.

I don't see why any of that should take any more than 5 minutes. Before I started programming in Python / Django I was a C programmer. Now that takes time because there are so many mistakes you can make in C unless you are on the ball. In comparison Python and Django is a piece of cake.

The thing that takes the time is planning out features and making sure your unit tests are comprehensive. Also making sure your models are well designed. I can easily spend 2 times the amount of time planning out features than I do actually programming and my philosophy when it comes to programming is have the absolute bear minimum of code in your views. If you can get rid of code then do so.

On 03/04/2017 16:10, Vijay Khemlani wrote:

Also

"I can write just about any view I want in less than 5 minutes with a
function based view. The only slow down on my end is my typing speed."

If your typing speed is the limiting factor in your workflow... *shudders*



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/30a5eab2-dee9-eaff-66e4-105ba85bf0bf%40googlemail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCfh-P3ZHqjuhE8v%3DRgcbWQ32rJMDQBQEn_UTTTkJnv_8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment