Django templates: how do I save an item inside a {% for %} loop? -


.

When a user searches only for the first name and I leave the query in the query and asks for the last name to enter it but I thought it would be good if the user only clicks on a name And the search results are returned directly (the link takes you back to search the form at this point.)

The query in the template and the last name that I need {in the lawyer lawyer Sector% inside} for loop is characterized as: lawyer. First and lawyer. I did not know how to save them to create a query. Can you help me with solving this problem?

Note: The template is below but I put it in pastebin.com. It's 60 lines long, I was not sure I should post it here.

Thank you.

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Search results & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; P & gt; You & lt; Strong & gt; {{First || Capfirst}} & lt; / Strong>. & Lt; / P & gt; Is searched for. & Lt; P & gt; {{Lawyers | Length}} {{first | Capfirst}} In the database please choose one. & Lt; / P & gt; {Lawyer for lawyer in%}} 
    gt; & Lt; Li & gt; & Lt; A href = "/ search /" & gt; {{Attorney.first}} {{attorney}}} {{attorney.ferm_name}} {{lawyer.range}} class {{lawyer.yur_graduated}} & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; {% Endfor%} & lt; Form action = "method =" get "& gt; {{Form.as_p}} & lt; Input type = "submit" value = "submit" & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;

edit

Do I need to create a new visual function like this?

  def new_query (requested): last_name = request.GET.get ('lawyers.') First_name = request.GET.get ('lawyer. First') ....   

Since you are using GET for your form, you can create a Form submissions can be fully simulated.

  & lt; A href = "? First_name = {{attorney} first}} and last_name = {{attorney}} & gt;  

this will send a request to the current URL (because we can not URL not specified, just get the parameter. It is equivalent to

  

But adding the form 2 parameter, called first_name, and last_name, as if it is called in your normal form - same view like this handle this request

If you have additional criteria in your form (such as year_of_graduate level), you will also need to add them.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -