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/206cfa0f-cdf8-4d44-827c-c703e298d782%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to