Hello,

I have in mind in a tiny app to allow user to set a search box with the 
provider they wish.

I base this on web_search and then did the following :

# Create your models here.
class SearchBox(models.Model):
     CROP_ANCHOR_STR = ('dmoz', 'ask', 'google', 'googlefr', 'excite', 
'msn', 'yahoo')
     CROP_ANCHOR_CHOICES = zip(range(len(CROP_ANCHOR_STR)), CROP_ANCHOR_STR)
     engine = models.SmallIntegerField(choices=CROP_ANCHOR_CHOICES)

     class Meta:
         verbose_name, verbose_name_plural = "Search Engine", "Search 
Engines"

and in my views, I did :


# Create your views here.
def results(request):
     """
     Get search engine set up for the site
     Get results for the query
     """
     engine_list=SearchBox.objects.all()
     for eng in engine_list:
         engine=eng.get_engine_display()
     if request.POST:
         return render_to_response('results.html', {'result': 
engine(request.POST['search'], 10), 'search_query': request.POST['search']})
     else:
            return render_to_response('results.html')

The issue is that engine in engine(request.POST['search'], 10) does not 
become google(request.POST['search'], 10) in the case where the user 
chosed "google" as engine.

Is there a solution or did I have to test all values with a if or case 
loops ?

Nicolas


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to