Hi,

Apparently you want an empty list if query has a value, and a list with one
element otherwise (so the "if query" works).

query_string = request.POST.get('q', '')
if query_string:
   query = [ query_string ]
else:
   query = []

Reading the Python tutorial probably wouldn't hurt.

Remco



On Jan 29, 2008 2:19 PM, MariusB <[EMAIL PROTECTED]> wrote:

>
> In the view take an URL from the query:
>        query = request.POST.get('q', '')
>
> and in the template I want to print it out in a list
>        {% if query %}
>                <ul>
>                {% for url in query %}
>                        <li>{{ url }}</l1>
>                {% endfor %}
>                </ul>
>                {% else %}
>                <p>No urls found</p>
>        {% endif %}
>
> How do I turn query from a string into a list with one element
> (['<query_value>']) in the view?
> >
>

--~--~---------~--~----~------------~-------~--~----~
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