hi i'm new with python and django and i work on search page of my site. in my html search form, user can choose table(or field) which want to search. in server-side i use sequences of 'if' to find chosen table(or field) and related django model. ... #here i assume searched fields have the same name('title') q = requst.GET['query'] tbl = requst.GET['table'] if tbl == 'Book': result = Book.objects.filter(title__icontains=q) if tbl == 'Author': result = Author.objects.filter(title__icontains=q) ... now is there any way to reduce or eliminate 'if' sequences? i test this and it works: ... tbl = eval(requst.GET['table']) ... but i'm not sure that is best way? thanks
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.