Why is views method not being invoked?
Question: I have a web directory with `urls.py` in a directory (RazorWare_Web) as
follows:

    
    
    from RazorWare_Web.views import home
    
    urlpatterns = patterns('',
                           url('/', home.index, name="index"),
                           url(r'^razorware/', include("RazorCRM_App.urls")),
                           url(r'^admin/', include(admin.site.urls)),
                           )
    

So in my browser, `http://localhost:8000/razorware` navigates to the `home`
view's `index()` method. I'm a little confused by this. I would expect
`http://localhost:8000/` would navigate to `home`. Instead this produces a url
not found error page.

Aside from that, the real problem (and I suspect it is related to the above)
exists when I perform a `$.getJSON` call from my HTML page. First, the actual
app exists under the sibling directory, RazorCRM_App, with the following:

    
    
    from RazorCRM_App.views import queries
    
    urlpatterns = [
        url(r'query_locale', queries.query_locales, name="query_locales"),
    ]
    

When I execute the following script:

    
    
    function query_locale_by_zip(){
        var post_code = txt_postal.val();
        $.getJSON("query_locale", {post_code: post_code}, function(result){
            console.log("[APP] query locale for: " + post_code + " [returned: " + result.success + "]")
        });
    }
    

... the `queries.query_locales` method is not being called. However, I do get
the following output from the console:

> [25/Feb/2015 15:20:51] "GET /razorware/query_locale?post_code=9 HTTP/1.1"
> 200  
>  [25/Feb/2015 15:20:51] "GET /razorware/query_locale?post_code=92 HTTP/1.1"
> 200  
>  [25/Feb/2015 15:20:51] "GET /razorware/query_locale?post_code=920 HTTP/1.1"
> 200  
>  [25/Feb/2015 15:20:52] "GET /razorware/query_locale?post_code=9205
> HTTP/1.1" 200  
>  [25/Feb/2015 15:20:52] "GET /razorware/query_locale?post_code=92058
> HTTP/1.1" 200

I might understand if there was a message stating that the url could not be
found. But this just seems odd.

Using Django version 1.7.1 and Python 3.4.2


Answer: Your root url should look like `url(r'^$', home.index, name="index")` and your
query_locale url should look like `url(r'^query_locale/$',
queries.query_locales, name="query_locales")`.

[url dispatcher](https://docs.djangoproject.com/en/1.7/topics/http/urls/) has
broad documentation about how urls work.

