0

I am having problems in production with my django project. It raises 'Matching query does not exist'. In my localhost works perfect, the error is only in my server.

The line with the error is a query

sub_obj = Sub.objects.get(name=name)

I cannot access the model by 'id' in this case because the view gets that parameter from the template via href:

<a href="/pr/sub/{{s.name}}">{{s.name}}</a> 

This error occurs when the name has blank spaces, for example name='My Name'. Can this have something to do with the server ? Is possible to be getting this error with parameters separated by blanks ? or could be something else ?

The url for this view is

url(r'^pr/sub/(?P<nname>.*)', show_only_sub),
jesicadev18
  • 2,942
  • 5
  • 22
  • 39
  • Is `nname` spelled properly? – rnevius Mar 18 '16 at 15:10
  • I've updated with url, the issue is only in my server ( works fine locally ), and it has something to do with query with blankspace. – jesicadev18 Mar 18 '16 at 15:10
  • Perhaps this http://stackoverflow.com/questions/120951/how-can-i-normalize-a-url-in-python can help you, but I would suggest to you that use a `slug` to use on the URLs, instead of the flat name. – Vladir Parrado Cruz Mar 18 '16 at 15:25

1 Answers1

0

Spaces in the name can cause problems. Try urlencoding the name inside the href.

<a href="/pr/sub/{{s.name|urlencode}}">{{s.name}}</a>
knelson
  • 126
  • 1
  • 6