Hello,

I have data entry clerks typing the data, so I cannot have them type
the titles twice.  Is there a command where I could strip the tags out
after the keywords are typed but before python goes to the database to
search?
This is the def:

query = request.GET.get('q', '')
    if query:
        qset = (
            Q(pubtitle__icontains=query) |
            Q(pubauthors__icontains=query)
        )

Thanks!

May

On Feb 6, 11:52 am, Jeff FW <[email protected]> wrote:
> The issue has nothing to do with your templates--it has to do with
> your data, and how you're searching it.  In the database, you have
> stored "Survival of <em>Shigella</em>".  If you do a regular text
> search (field__contains, or similar) for "Survival of Shigella",
> you'll never get a match, because those strings don't match.
>
> There are a few ways to deal with this, but I think one of the
> cleanest would be to actually store *two* versions of the fields you
> need to search: one with whatever HTML you need, and one with all of
> the tags stripped out.  Then, you perform the searches on the stripped
> field(s), but display the "real" field.  You can override your model's
> save() method to actually set the stripped field.
>
> -Jeff
>
> On Feb 6, 1:12 pm, May <[email protected]> wrote:
>
> > In the database I need to italics species names ex.  Survival of
> > <em>Shigella</em>
> > In the search template I use the following:
>
> > <form action="." method="GET">
> >     <label for="q">Search for Publications: </label>
> >     <input type="text" name="q" value="{{ query|safe}}">
> >     <input type="submit" value="Search">
> >   </form>
>
> > When a user types in "Survival of Shigella" the search code finds no
> > record, because I think the <em> tags are hindering the search
> > somehow.   When I type in Shigella the search finds the record.   I
> > have changed the
> > value = {{query|safe}} to all combinations (escape, force_escape,
> > escapejs, iriencode, urlencode) and I still can't get the search to
> > work.  Anyone have a suggestion on one; either using different html
> > tags for italics or two; suggest how to get the search to strip the
> > tags?
>
> > Thanks,
>
> > May
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to