On 8/7/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Sat, 2006-08-05 at 08:36 -0700, jeffmikels wrote:
> > I'm trying to create a site that has entries of different types and
> > tags that can link to any type of entry.
> >
> > In my models, I have a
> >
> > <code>tags = models.ManyToManyField(Tag, blank=True,
> > filter_interface=models.HORIZONTAL, related_name="tags")</code>
> >
> > when using generic views and form.tags, I get a select box; however, i
> > would rather have a single text box into which I can type a string of
> > comma separated tags, and then have them parsed behind the scenes. Can
> > I still use generic views, or do I have to roll my own view?
>
> You will need your own view for this, because you have to do some
> customised processing of the input data before you put it into your
> model. Don't panic, though, those sort of form processing views are not
> hard to write. Just follow the example in [1] and replace the "send
> email bit" with "split up the input on commas and insert into objects".
>
> [1]
> http://www.djangoproject.com/documentation/forms/#custom-forms-and-manipulators

Agreed. I had to do something similar over the weekend (user
self-registration, saving a user profile and user account, sending
admin e-mail and logging the new user in), and it was trivially easy.
The models docs + auth docs + custom forms and manipulators docs are
very well written. By using validators I was even able to keep my view
code down to the bare essentials and rely on the
manipulators+validators to ensure that the input was sane.

It all felt very natural when done using the framework.

Make sure you keep the documentation open while you're doing this, and
actively look for opportunities to move work to your validators. If
you try to keep within the design of the framework you'll end up with
simple code and results you're very happy with (and a lot of things
will just work).

Good Luck!
Michael

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to