Wednesday, February 27, 2013

Re: I need a form that allows users to select from a list of choices, or add a new choice.

Remember, it's just Python. In the end, all you need is for the
'choices' of the field (which is just an iterable) to contain the
value after the form's __init__ so that the form won't consider the
value invalid.

You could:

1. Have a pop-up form that allows the user to submit the new choice
via AJAX, then use JavaScript to update the dropdown.

2. Have a text box which they can fill in and leave the drop-down
blank, then take the appropriate actions in the view.

3. Whatever else works.

As always, beware of user input. But it's not a hard problem to solve.
It's a bit easier if the choices come from a model, so you can just
add new instances to that model as users add them so they're retained
for other visitors.

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment