i have 1 thing , need suggest. please me on this.
my scenario is: have 1 model ordercode in table have prefix
1 | 12 | canada 13 | uk 134 | australia
and more. then, have string 12345678, , need best match string .
if user enter 12345678 best match 12|canada , if user enter 135678975 best match 13|uk, , if user enter 1345676788 best match 134.
how can in django query?
thanks,
it require multiple request check every char in given order code...
def get_matching_country(order_num): = 1 matching_req = country.objects.none() while true: req = country.objects.filter(country_code=order_num[:i]) if res.exists(): matching_req = req += 1 else: break return matching_req
Comments
Post a Comment