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

  • SEARCH
  • Home
  • 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 7161691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:36:32+00:00 2026-05-28T13:36:32+00:00

Has anyone successfully done this? Trying to replicate functionality similar to what is found

  • 0

Has anyone successfully done this?

Trying to replicate functionality similar to what is found at
http://www.walmart.com/cservice/ca_storefinder.gsp

Where the user can enter either a city, state or zipcode and have an intelligent lookup

I started an attempt using a bit of regex and splitting fields though I quickly realized this was a task that would take more than a little bit of thought to make it work intelligently for the end user

approaches considered

  • live ajax auto-complete calls
  • Sphinx full text search
  • regex search db side
  • regex validate user input

snippet thus far below

import re

from general.models import ZipCode

def findLocation(value):
    match = re.search(r"\d{5}", value)
    if match:
        try:
            return Zipcode.objects.get(zip=value)
        except ZipCode.DoesNotExist:
            return False
    else:
        kwargs = {}
        vals = value.split(',')
        if len(vals) > 1:
            kwargs['city'] = value[:len(value)-len(vals[-1])-1]
            state = vals[-1].strip()
            if len(state) == 2:
                kwargs['state'] = state
                else:
                kwargs['state_name'] = state
        else:
            kwargs['city'] = value
        return ZipCode.objects.filter(**kwargs)

ZipCode in this example is a database model that contains a all US zip codes / states / state abbreviations / cities
there is a copy available on github at

https://github.com/amites/django-general

  • 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-28T13:36:33+00:00Added an answer on May 28, 2026 at 1:36 pm

    For this kind of advanced feature, you’d better use some dedicated tool, like the Solr search engine.

    If you don’t know it, it’s a java based, open-source, very powerful search engine, with the ability to add location search features. The search actions will be performed through a web service (xml, json, etc.)

    The steps are basically the following: you install solr on a server, you configure a schema (a way to store and index data), import data from you database, and bind your search form to the web service.

    You might want to read this article to have more informations about geolocation searches (maybe slightly outdated, you’ll have to check).

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

Sidebar

Related Questions

Has anyone successfully done this? My idea is to post to a servlet and
Has anyone done this successfully? As I understand, GDI+ 1.1 only ships with Vista.
Has anyone done this or attempted to do this for a preexisting project? It
This should be a snap for anyone who's done it before... I'm trying to
I am trying to done that tutorial http://blog.springsource.com/2011/01/04/green-beans-getting-started-with-spring-mvc/ but I am stuck just before
Has anyone successfully implemented a Java based solution that uses Microsoft SQL Server 2005
Has anyone successfully talked profibus from a .NET application? If you did, what device/card
Has anyone successfully installed VS 2008 Team Developer edition on the Windows 7 beta
Has anyone successfully bound 2 textboxes to one DateTime property using the model binding
Has anyone successfully mapped a numeric array in PostgreSQL to a numeric array in

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.