Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3317126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:33:02+00:00 2026-05-17T22:33:02+00:00

Hello I have been recently working on Django search forms recently and have tired

  • 0

Hello I have been recently working on Django search forms recently and have tired to edit one myself. Here is a search form that is supposed to find Clients. However When I type in a clients name, it does not display that client’s name. So I am wondering What I am doing wrong.

    #model.py
    class Client(models.Model):
        company = models.CharField(max_length=80)
        first_name = models.CharField(max_length=80, blank=True, null=True)
        last_name = models.CharField(max_length=80, blank=True, null=True)
        address = models.CharField(max_length=250)
        city = models.CharField(max_length=100)
        country = models.CharField(max_length=120)
        postcode = models.CharField(max_length=7)
        telephone = models.CharField(max_length=20)
        email = models.EmailField()
        additional_info = models.TextField(blank=True, null=True)

        def __unicode__(self):
                return self.company
#views.py
@login_required
def search_client(request):
    query = request.GET.get('q', '')
    if query:
        qset = (
        Q(company__icontains=query) |
        Q(address__icontains=query) |
        Q(postcode__icontains=query)
        )
        results = Client.objects.filter(qset).distinct()
    else:
        results = []
    return render_to_response("search_clients.html", {
        "results": results,
        "query": query
}, context_instance=RequestContext(request))


    #search_clients
{% extends "base.html" %}  

    {% block content %}
    <h1>Search</h1>
      <form action="." method="GET">
        <label for="q">Search: </label>
        <input type="text" name="q" value="{{ query|escape }}">
        <input type="submit" value="Search">
      </form>

      {% if query %}
        <h2>Results for "{{ query|escape }}":</h2>

        {% if results %}
          <ul>
          {% for clients in results %}
            <li>{{ clients|escape }}</l1>
          {% endfor %}
          </ul>
        {% else %}
          <p>No clients found</p>
        {% endif %}
      {% endif %}
    {% endblock %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:33:03+00:00Added an answer on May 17, 2026 at 10:33 pm

    Ok looks like somehow it know works properly. The odd thing is I don’t know how it started to working properly. I may have restarted the server again while making changes or may have been my urls.py file. I really don’t know but seems ok now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been recently working on an easy to use Syntax Highlighting system for
Hello i have been trying to find a tutorial that show how to setup
Hello i have been trying to find a tutorial that show how to setup
Imagine I have the following: inFile = /adda/adas/sdas/hello.txt # that instruction give me hello.txt
I have a file called hellowf.cs class MyFirstApp { static void Main() { System.Windows.Forms.MessageBox.Show(Hello,
Hello I have recently uploaded an application to the app store and it got
I have been playing around with php-gtk recently and in the past I have
Recently I saw this piece of JavaScript code, but have been unable to understand
DUPLICATE How to do version numbers? Hello, So I recently saw that Groovy was
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.