Monday, April 3, 2017

Re: Will function based views ever be deprecated?

Hi,

Awesome thanks. I can see the reason for some class based views as they
remove the need for boilerplate code but if you run into a problem with
them for whatever reason you generally have to dig out the Python
debugger and set a break point in your view to see what the Django
framework code is doing in the background.

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. I
just find them much easier to understand and debug when you can look at
the entire code for the view with nothing else getting in the way.

I think I will try again to use some class based views in my code just
so I can make a more informed decision. I just remember my last attempt
to use the FormView class based view with multiple forms on the same
page and giving up in disgust because it was so much harder than doing
the same thing in a function based view.

Some Developer.

On 02/04/2017 06:37, James Bennett wrote:
> If you're asking "Will there ever be a point when all built-in views in
> Django are class-based", the answer is "maybe", because whether to write
> one of those class-based or function-based depends on what the view
> needs to do, how much configurability/extensibility it needs to support,
> etc.
>
> If you're asking "Will there ever be a point when Django no longer
> supports using functions as views, period", the answer is almost
> certainly "no".
>
> Officially, the definition of a Django view is a Python callable which
> takes an HttpRequest object as its first positional argument, and which
> either returns an HttpResponse object or raises an exception. That
> definition is unlikely to change.
>


--
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/e8af988b-3fd2-f781-e33b-00fa9b2b205f%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment