Donn, Daniel,

Thanks for your advice. I combined both your ideas together and now
have a solution to my problem.

It was pretty difficult though; that documentation is a little hard
core. For example, there were references to post_save_redirect
throughout the documentation but no explanation or example of where to
put it. Eventually, I stumbled across an answer on these mailing lists
(the solution I found was to pass the model and post_save_redirect by
putting them both into dict())

I'm really exited about Django and I can already see that it is an
amazingly powerful framework that would make it possible to build
complex applications quickly and efficiently. However, although the
first 4 chapters of the documentation tutorials got me really far,
beyond that point it has felt so far like I reached the end of a path
only to find myself in the thick of a jungle.

I'm enjoying learning though, and really appreciate the help from the
people on this list.

Thanks

On Nov 24, 11:12 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Nov 24, 11:59 am,dash86no<[EMAIL PROTECTED]> wrote:
>
>
>
> > I've implemented a search function which brings up a list of database
> > items on a page. My template looks like this:
>
> > {% extends "base.html" %}
>
> > {% block content %}
>
> >     {% if results %}
> >       <ul>
> >       {% for quote in results %}
> >         <li>{{ quote|escape }}</l1>
> >       {% endfor %}
> >       </ul>
> >     {% else %}
> >       <p>No quotes found</p>
> >     {% endif %}
> > {% endblock %}
>
> > My search code is like this:
>
> > def search(request):
> >     query = request.GET.get('q', '')
> >     if query:
> >         qset = (
> >             Q(name__icontains=query) |
> >             Q(company__name__icontains=query) |
> >             Q(note__icontains=query)
>
> >         )
> >         #results = Quote.objects.filter(qset).distinct()
> >         results = Quote.objects.filter(qset)
> >     else:
> >         results = []
>
> >     return render_to_response("sam_app/search.html", {
> >         "results": results,
> >         "query": query
> >     })
>
> > The problem, is that the outputted list is just static text. What I
> > want, is a series of links that when I click one one of them, will
> > bring up the relevant item in a form for editing.
>
> > I found 
> > this:http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index
>
> > And saw the form.as_p form.as_table form.as_ul and got exited because
> > I thought this might work. I edited the above code to make the search
> > function pass a form object to the template, but then I got the error:
> > Caught an exception while rendering: too many values to unpack.
>
> > So I guess this isn't it?
>
> > I know I could just put together a loop to generate links with the pk
> > encoded inside the url, and do it like that, but it seems to me there
> > should be a neat little method in django to do this automatically. It
> > also though generic views might be the answer but I don't think you
> > can customize those, right?
>
> > Cheers,
>
> You can use the create/update generic views[1] to provide the actual
> edit pages. Once they are linked in your urls.py, you can use the {%
> url %} tag[2] to link to them from your list template.
>
> [1]:http://docs.djangoproject.com/en/dev/ref/generic-views/#create-update...
> [2]:http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
>
> --
> DR.
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to