using __gte in django queryset -


I have a search where this is doing.

Template

  & lt; Input class = "category-slider-3" type = "text" name = "year" & gt;  

see

  yrs = request.POST.get ('year') user = user.object.filter (years_of_exp__gte = yrs)  

This returns years_of_exp to all users regardless of the queryset numbers, if I put 100 or 40 or 44 or 78 in the search box, I get all the users Even if they have DB in years_of_exp 2.

Why is this happening? Maybe something is wrong doing

You are retrieving yrs as a string and the integer is the comparison of the value , Which will result in comparisons like this:

  '2' & gt; = 100  

Unfortunately (for you) is true in dragon 2. X

You must enter yrs for an integer:

  yrs = int (request.post.get ('years'))  
< / Div>

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -