Hi Tdkwon,

What the benefits using django forms something like :

1. You can reuse it on another view programmatic way, not copy paste html only
2. You have the definition of form in  1 place rather distributed on many views 
to change it.
3. You have the helptext, error message, validation, css class 
4.little code in views to process form data and save to models

Try it and tou will found it more usefull

Regards,

Mulianto
Blog: http://muliantophang.blogspot.com


Sent from my iPhone

On 10 Des 2014, at 09:01, T Kwn <tdk...@gmail.com> wrote:

> Thx for the explanation. I thought as much but as a beginner am always 
> worried about some unforseen consequence.
> 
> On Tuesday, December 9, 2014 1:26:47 AM UTC-8, Daniel Roseman wrote:
>> 
>> On Tuesday, 9 December 2014 01:37:44 UTC, T Kwn wrote:
>>> 
>>> I'm created a form where a user can add or remove other users from a group. 
>>> Because the number of available users is unknown beforehand, I needed to 
>>> create a checkbox form where the number of elements is dynamic. However, I 
>>> couldn't figure out how to do it so I just used an html form and some 
>>> <input type="checkbox">. I then processed the result in my view. I do not 
>>> have any form defined in forms.py.
>>> 
>>>  I presume this is poor django practice but I'd like to know more details 
>>> on why. Obviously I'm not getting the built-in form validation but with 
>>> checkboxes it doesn't seem very necessary. Anything else?
>>> 
>>> My view can be seen here:
>>> 
>>> https://gist.github.com/anonymous/d1e8bd43c20eced9e4ce
>>> 
>>> The template code is pretty basic such as:
>>> 
>>> {% for myuser in members %}
>>>     {{ myuser.username }}
>>>     <input type="checkbox" value="{{ myuser.username }}" name="delete_me"/>
>>>     <br>
>>> {% endfor %}
>> 
>> There's nothing wrong with doing that, of course. Just as you can write raw 
>> SQL to talk to your database, and even raw WSGI to power your web app. But 
>> Django provides utilities like the ORM, and the forms framework, to make it 
>> easier for you. If you find they don't help for your use case, then feel 
>> free not to use them.
>> --
>> DR.
> 
> -- 
> 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+unsubscr...@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/3e6d5ef4-ed66-46d1-9906-f2de823fb311%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+unsubscr...@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/EB8EB001-2DDC-4ACB-8EBF-1E2899781976%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to