Hello,
I'm not a Django contributor, just a user, but please allow me to express my opinion that CBVs are an extra layer of functionality that seems to have made it into the foreground attention since it was introduced, but I think that that is very unfortunate:
CBVs bring not only extra functionality, but also complexity. With that, they obscure the three-paths idea that is used in FBVs (no POST data, POST data that validates with errors and without). Yes, the three-paths method seems like a tedious pattern that must repeatedly be written by hand. But in my opinion, it clearly expresses a key concept that is very important for beginners to understand, especially as beginners that are new to Django often are new to web development as well.
Kyle seems to have experience with web development, but all the more his question is a prime example of that issue.
In my opinion, DRY is not above all. I've been using Django for years and have never found CBVs attractive but for a narrow range of use cases.
Personally, I think that both in examples, courses and the Django tutorials the focus should be on FBVs. Only then and only on this basis should CBVs be introduced, with an emphasis on how they emerged from FBVs.
Best regards,
Carsten
Am 14.03.19 um 07:56 schrieb Luke Plant:
> Hi Kyle,
>
> My take would be this: What does the code look like if you don't use FormView but just write a function view? How does that compare to using a CBV? This may be the simpler method you are missing - if you are finding you are fighting with inherited functionality, just don't inherit it.
>
> Luke
>
>
> On 09/03/2019 03:55, Kye Russell wrote:
>> Hi,
>>
>> Sometimes it is appropriate to for a HTML form to use the GET method for submission (usually search / filter forms).
>>
>> My impression has always been that in order to build a FormView-based view that acts on GET data, you have to override a few methods on your class (which involves understanding how FormView works). Even as someone with a fairly good understanding of these classes, I sometimes have to reference a previously-written example to make sure I've got it right.
>>
>> I am aware of the existence of django-filter[0] which takes care of this for you, however at times I find it hard to justify adding it to a project just to deal with this.
>>
>> I have the following questions:
>>
>> * Is my understanding of the current process correct, or is there an easier way that I've missed?
>> * Is this documented anywhere? I looked at the Django 'working with forms' documentation[1], and whilst it discusses the different scenarios in which you'd use GET vs POST, it does not seem to discuss implementations in a CBV context.
>> * Is there enough of a generic use-case where FormView / FormMixin / ProcessFormView could be altered to support this? Or are there subtleties / nuances in each implementation that make a generic solution hard to develop?
>>
>> Sorry if this is the wrong avenue to discuss this. I am approaching it from the position of wanting to alter Django to better support this use case, but I'm aware that I may have just missed a Blessed method in the docs.
>>
>> Kye
>>
>> [0]:
https://github.com/carltongibson/django-filter
>> [1]:
https://docs.djangoproject.com/en/2.1/topics/forms/
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to
django-develop...@googlegroups.com <mailto:
django-develop...@googlegroups.com>.
>> To post to this group, send email to
django-d...@googlegroups.com <mailto:
django-d...@googlegroups.com>.
>> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/CANK-ykkMtxezA9cHN8jQ_czLn6OYtdDn6JYbjNgASyyqHH-aAw%40mail.gmail.com <
https://groups.google.com/d/msgid/django-developers/CANK-ykkMtxezA9cHN8jQ_czLn6OYtdDn6JYbjNgASyyqHH-aAw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> --
> You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
django-develop...@googlegroups.com <mailto:
django-develop...@googlegroups.com>.
> To post to this group, send email to
django-d...@googlegroups.com <mailto:
django-d...@googlegroups.com>.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/668e083b-d3c1-8a5b-989e-03a0a85d895a%40cantab.net <
https://groups.google.com/d/msgid/django-developers/668e083b-d3c1-8a5b-989e-03a0a85d895a%40cantab.net?utm_medium=email&utm_source=footer>.
--
Dipl.-Inf. Carsten Fuchs
Industriegebiet 3 ℅ Rofu
55768 Hoppstädten-Weiersbach
https://www.cafu.de