Created
August 25, 2011 07:16
-
-
Save zachwill/1170147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def category(request, model, tag): | |
""" | |
Given a lowercase model name and tag, search for all models linked to | |
the given tag. The model is obtained by looking through a dictionary of | |
available models. | |
""" | |
available_models = {'apps': App, 'data': Data, 'ideas': Idea} | |
try: | |
actual_model = available_models[model] | |
except KeyError: | |
# The model does not exist. | |
context = {'results': None} | |
else: | |
results = actual_model.objects.filter(tag=tag) | |
context = {'results': results} | |
return render_response(request, 'category.html', context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment