Monday, December 22, 2014

Re: Model form with optional fields issue

That seems like a bit of a broad brush stroke against Django. Have you looked at the Django REST Framework module? It can often utilize your existing views, and has support for partial updates.

http://www.django-rest-framework.org/api-guide/serializers/#partial-updates

Django is primarily used for displaying/validating data received from HTML forms, hence the bias towards that behavior where partial updates are not common. However, the internal behavior is decoupled enough that the behavior you desire can be easily attained, hence the Django REST Framework.

-James

On Dec 22, 2014 9:14 AM, <marcin.j.nowak@gmail.com> wrote:

> What do you think - is this expected?

Yes, this is expected. Django's form system is designed for use with
HTML forms, which do not provide partial data: unchanged field values
are sent too, so this problem does not occur.

I thought that Web framework can validate RESTful(-like) requests (like PATCH or even GET), but I see that without redesigning/overriding built-in forms it is not possible.. :(

I would like to say that in my opinion validation and cleaning (forms essentials) should be decoupled from HTML input and rendering. 
Without that, forms are only partially usable. It's a design issue, IMO.

Nowdays I'm creating more apps with separated clients written in pure js, and I need solid backend. 
Input cleaning, validation and processing logic is the most important thing.
But with validation designed mostly for plain-old-html input I can't rely on Django as a web framework.
That's sad, because I like it for rapid development. 

Kind Regards,
/Marcin

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d15de090-649f-4e95-9262-f2f22462598f%40googlegroups.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUogS2FsmYKxfSkAFdfAJKeo4_rNivY6qbP%2B16SmV-POw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment