javascript - Using a URL as a URL parameter in Django Rest Framework -


i have model unique field address. thing is, trying instances of model using ajax.

var address = 'http://example.com/blog/2/';  $.ajax({     url: 'http://sitemy.com/api/get_content/'+encodeuricomponent(address),     type: 'get',     datatype: 'json',     success: function(json) {         console.log('success');     } }); 

in urls.py, have following code:

url(r'^api/get_content/(?p<url>.+)/$', views.get_content), 

so trying use url pattern capture request. however, getting 404 error since url sent request not match pattern. gives? how can solve this?

in case important, in views, doing following:

def get_content(request, address):     try:         content = content.objects.get(address=urllib.unquote(address))     except:         return response(status=status.http_404_not_found)      if request.method == 'get':         serializer = contentserializer(content)         return response(serializer.data) 

any appreciated. also, welcome general advice regarding encoding of urls, boggles mind reason. thanks.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -